如何将长值转换为KB字符串格式
问题描述:
如何像快照图片一样以KB表示长值?
How do I represent a long value in KB like the snapshot picture?
答
这可能是您要查找的内容:
This is probably what you're looking for:
long memory = 210957130;
Console.WriteLine("{0:N0} K", memory / 1024);
Console.WriteLine(string.Format(new CultureInfo("en-US"), "{0:N0} K", memory / 1024));
如果您想使用当前区域设置中的千位分隔符,请使用第一个选项.如果您特别想使用逗号,请使用第二个选项.
If you'd like to use the thousand separator from your current regional settings, use the first option. If you specifically want to use a comma, use the second option.