SYSK 107: The Difference Between Decimal.ToString(“C”) and Decimal.ToString(“C2”)

Formatting string “C2” explicitly tells to leave two decimals.  One could also use “C0” (no decimals), “C1”, “C3”, “C4”. Many believe that there is no difference between the format strings “C” and C2”.   While it’s true in the default scenario, it’s only the case since CurrencyDecimalDigits is initialized to 2.  However, in the code below ToString(“C”) results in 4 decimal digits, just like “C4”, not “C2”:

System.Globalization.NumberFormatInfo nfi = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat;

nfi.CurrencyDecimalDigits = 4;


decimal x = 5.3428M;          





Comments (1)

Skip to main content