I need to convert a decimal to a string with N decimals (two or four) and NO thousand separator:
'XXXXXXX (dot) DDDDD'
The problem with CultureInfo.InvariantCulture
is that is places ',' to separate thousands.
UPDATE
This should work for decimal and double types.
My previous question: Need to convert double or decimal to string
For a decimal
, use the ToString method, and specify the Invariant culture to get a period as decimal separator:
value.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
The long
type is an integer, so there is no fraction part. You can just format it into a string and add some zeros afterwards:
value.ToString() + ".00"