I encountered the same problem as you. People wanted decimal places to be formatted in crazy user-friendly ways throughout the application.
My first idea was to create a wrapper around Decimal and override the ToString () method.
Although you cannot inherit from Decimal, you can create a type that is implicitly dropped into and out of decimal code.
This creates a facade in front of Decimal and gives you a place to write custom formatting logic.
Below is my possible solution, let me know if this works, or if this is a terrible idea.
public struct Recimal { private decimal _val; public Recimal(decimal d) { _val = d; } public static implicit operator Recimal(decimal d) { return new Recimal(d); } public static implicit operator Decimal(Recimal d) { return d._val; } public override string ToString() {
It works the same as decimal:
Decimal d = 5; Recimal r = -10M; Recimal result = r + d;
source share