For this you can use a format string, see
Standard numeric format strings
e.g. N2 for numeric with 2 decimals.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hey Community,
I have a string which I want to transform from:
5000000,00
to
5.000.000,00
I hope that you can help me. The programming language is C#. I need a replacement which is dynamically because the string can have values like 5,00, 1.000,00, 1.000.000.000,00 etc.....
Best regards
Timgo1001
For this you can use a format string, see
Standard numeric format strings
e.g. N2 for numeric with 2 decimals.
The string can be converted to number before formatting, for example:
string s = "5000000,00";
var c = CultureInfo.GetCultureInfo( "de" );
string result = decimal.Parse( s, c ).ToString( "#,##0.00", c );
// Result: 5.000.000,00
Use the appropriate culture.