Decimal money = 7;
var result=money.Tostring("C);
result displays $7.00
How can i show result as "7.00"( with 2 numerics after point) without currency symbol?
Decimal money = 7;
var result=money.Tostring("C);
result displays $7.00
How can i show result as "7.00"( with 2 numerics after point) without currency symbol?
"C"
Format Specifier is for currency representation of numbers. It uses your CurrentCulture
's CurrencySymbol
and CurrencyDecimalSeparator
properties as a result. (If you don't use IFormatProvider
as a second parameter, of course..)
You can use N2
format insead. Like;
decimal money = 7;
money.ToString("N2").Dump(); //7.00
or
Console.WriteLine(money.ToString("N2"));
Read:
Result: Integral and decimal digits, group separators, and a decimal separator with optional negative sign.
Supported by: All numeric types.
Precision specifier: Desired number of decimal places.
Standard format can do this:
var result = money.Tostring("N2");
Reference:
Look under "N" or "n"
.
Try this :
var result = money.ToString("f");