String format to add commas in thousands place for a number
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class Program { static void Main(string[] args) { string s = string.Format("{0:n0}", 1234567890); Console.WriteLine("number: 1234567890"); Console.WriteLine("Thousands Separator: " + s); Console.WriteLine("\nanother solution"); int number = 1234567890; string formatedstring = number.ToString("#,##0"); Console.WriteLine("result: " + formatedstring); Console.ReadLine(); } } |
Output:
1 2 3 4 5 6 7 | number: 1234567890 Thousands Separator: 1.234.567.890 another solution result: 1.234.567.890 |