My Technical Notes

Tuesday, 11 November 2014

Formatting a Decimal to display a Financial Value

If we have a decimal representing a price, for example, then we want to display the decimal to two decimal places. We used `ToString` method with the specifier `F` for that:

decimal m = 19.11M;
string mStr = m.ToString("F"); // 19.11

No comments: