How to format double without fractional part

2020-04-21 07:21发布

问题:

The value am sending is 100233

double value = 100233;
string a = (value.ToString("N", CultureInfo.InvariantCulture));

output 100,233.00 but i want 100,233 i don't want the trailing zeros . Is there any specific way to get it ?

回答1:

you are close

double value = 100233;
string a = (value.ToString("N0", CultureInfo.InvariantCulture));