In this C# tips and tricks blog post , we look at how to use String.Format function to display the commas in the thousand’s place for a number in C#.
Assume that you have an integer 123456 and you would like to format it to display the comma as for the thousand’s seperator. You can use the string.format function and pass “N” for the format specifier (first) parameter as shown below.
string.Format(“{0:n}”, 123456);
This will display the output as 123,456.00
Incase you don’t want to display the decimal , you can pass the format specifier as N0 instead of N as shown below.
string.Format(“{0:n0}”, 123456);