Reputation: 815
Since 3 days I'm searching this but I can't find something useful. I just want to format number like 12345
to 12.345
but all examples with comma, I want to use thousand seperator with "dot"
I checked this example also Custom Numeric Formatting but it's working on my server but not working on customer server? Always showing with comma?
Upvotes: 1
Views: 81
Reputation: 242
NumberFormatInfo nf = new CultureInfo(CultureInfo.CurrentCulture.Name).NumberFormat;
Console.WriteLine(12345.ToString("N0", nf));
nf.NumberGroupSeparator = ".";
Console.WriteLine(12345.ToString("N0", nf));
nf.NumberGroupSeparator = "z";
Console.WriteLine(12345.ToString("N0", nf));
Upvotes: 1
Reputation: 157048
It all depends on the code used in conjunction with the regional settings of your machine.
If you use this code, it will use the default regional settings of your machine (if you didn't deviate in your program):
string s = 12345.ToString("N0");
If you want to use a specific culture (one that had a .
as thousand separator), you can supply that to the method:
string s = 12345.ToString("N0", new System.Globalization.CultureInfo("nl-nl"));
Upvotes: 2