'string.Format give wrong thousand seperator in html razor C# block

string.Format("{0:#,0}",19091507)

string.Format give wrong thousand seperator in html razor C# block Expected Output : 19,091,507 Current Output : 1,90,91,507

Please help me.



Solution 1:[1]

You can try following.

        int @value= 19091507;
        Console.WriteLine(@value.ToString("#,#.##", System.Globalization.CultureInfo.CreateSpecificCulture("en-US")));

For me following is also working.

        int @value= 19091507;
        Console.WriteLine(string.Format("{0:#,#.##}", @value));

You can also try.

        int @value= 19091507;
        Console.WriteLine(string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"),"{0:#,#.##}", @value));

It depends on your culture.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1