I need to convert a string to a monetary format of {###}.###.###,##
that is
a value of 5461497702600
would become
54.614.977.026,00
The numbers become excessively large.
I am using
return string.Format("{0:#" + (val < 1000 ? "" : "\\.") + "##0.00}", val);
which returns for the example
54614977.026,00
(only one dot)
Any help would be appreciated
It is simpler than you seem to think, just use:
It is essential to use
decimalhere. The #,##0.00 picture is a very standard way of doing this, the output will use the system default symbols and the fromatter is smart enough to repeat the 3 digit grouping as needed. Use the following overload to specify a Culture, this example with the InvariantCulture will always use a decimal point: