Search code examples
c#numbersnumber-formatting

How to put thousand seperator "point"


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?


Solution

  •         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));