I am storing a variety of different sizes as a decimal in SQL server, such as:
10oz, 3.3oz, 100ml, 1.75litres
When I pull this number out as a decimal and do ToString() I end up with too many extra digits such as
10.000, 3.300, 100.00, 1.750
What I want is basically this :
decimal.Parse("1.7500").ToString().TrimEnd('0', '.')
to get me 1.75
or 10
I cannot seem to figure out the format string for this.
In Visual Studio debugger if I do decimal.Parse("1.7500")
it will show it to me as 1.75
but when I do ToString()
it becomes 1.7500
.
Decimal.Round(...) is no good because the format is not fixed.