Formatting numbers in .NET is very easy and it's very easy to forget how to do it. Here are a few simple .NET number formatters to remeber.
int int_value = 0;
double double_value = 0;
/////////////////////////////////////////////format an int with commas
int_value = 1231231232;
Console.WriteLine(int_value.ToString("N0"));
//1,231,231,232
/////////////////////////////////////////////format a double/decimal with commas
double_value = 1231231232.44444444444444;
Console.WriteLine(double_value.ToString("N"));
//1,231,231,232.44
/////////////////////////////////////////////format a double/decimal with a set number of decimal places
double_value = 1231231232.44444444444444;
Console.WriteLine(double_value.ToString("F"));
//1231231232.44
double_value = 1231231232.4;
Console.WriteLine(double_value.ToString("F2"));
//1231231232.40
double_value = 1231231232;
Console.WriteLine(double_value.ToString("F2"));
//1231231232.00
/////////////////////////////////////////////format a double/decimal with a set number of decimal places and commas
double_value = 1231231232.44444444444444;
Console.WriteLine(double_value.ToString("N3"));
//1,231,231,232.444
double_value = 1231231232.4;
Console.WriteLine(double_value.ToString("N3"));
//1,231,231,232.400
double_value = 1231231232;
Console.WriteLine(double_value.ToString("N3"));
//1,231,231,232.000