I am using the format ToString("0,0") to display a number like
我使用格式ToString(“0,0”)来显示一个数字
5000 as 5,000but if the number is 0 - 9, it displays 01, 02, 03, etc. Does anyone know the correct syntax so it does not display the leading 0?
Thanks, XaiSoft
3 个解决方案
#2
What you are looking for is the string formatter "N0". Example:
你要找的是字符串格式化程序“N0”。例:
int x = 10000;
int y = 5;
Console.WriteLine(x.ToString("N0"));
Console.WriteLine(y.ToString("N0"));
Prints:
10,000
5
More information here.
更多信息在这里。
#3
ToString("N0")
#1
#2
What you are looking for is the string formatter "N0". Example:
你要找的是字符串格式化程序“N0”。例:
int x = 10000;
int y = 5;
Console.WriteLine(x.ToString("N0"));
Console.WriteLine(y.ToString("N0"));
Prints:
10,000
5
More information here.
更多信息在这里。
#3
ToString("N0")