在C#格式号码 [英] format number in C#

查看:138
本文介绍了在C#格式号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
。NET的String.Format()来添加逗号在千位为一些

如何在C#中数1234567格式化为1,234,567?

How to format a number 1234567 into 1,234,567 in C#?

推荐答案

有关 Int32.ToString格式选项(),看到 href=\"http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx\">或的这里

例如:

string s = myIntValue.ToString("#,##0");



同样的格式选项可以在使用的String.Format,如

The same format options can be use in a String.Format, as in

string s = String.Format("the number {0:#,##0}!", myIntValue);

这篇关于在C#格式号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆