如何格式化十进制数字? [英] How To Format Decimal Digits?
本文介绍了如何格式化十进制数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望有一个数字逗号。有可能吗?
<前lang =cs> 十进制 Val1 = 155000 跨度>;
textBox1.Text = string .Format( {0:N2},Val1);
以上代码O / P
155,000.00
但我希望有1,55,000.00这可能吗?
谢谢解决方案解决方案:
int number = 1000000000 ;
string whatYouWant = number.ToString( #,## 0);
设置@ Page指令的Culture和UICulture属性
。 aspx页面
<![CDATA [<%@ Page UICulture = hi 文化 = hi-IN %>
C#.page
德cimal Val1 = 155000 ;
TextBox textBox1 = new TextBox();
textBox1.Text = string .Format( {0:C2},Val1);
更新:
textBox1.Text = < span class =code-keyword> string .Format( {0:N2},Val1);
是 - 请看这里: https://msdn.microsoft.com/en-us/library/syy068tk(v = vs.90).aspx [ ^ ]
你需要选择CultureInfo(hi-IN)IIRC
Hi, I wish to have a Commas for digits. Is it possible?
decimal Val1=155000;
textBox1.Text = string.Format("{0:N2}", Val1);
The Above Codes O/P
155,000.00
But I wish to have 1,55,000.00 Is it possible?
Thanks
解决方案
Solution:int number = 1000000000; string whatYouWant = number.ToString("#,##0");
Set the Culture and UICulture attributes of the @ Page directive
.aspx Page
<![CDATA[<%@ Page UICulture="hi" Culture="hi-IN" %>
C#.page
decimal Val1 = 155000; TextBox textBox1 = new TextBox(); textBox1.Text = string.Format("{0:C2}", Val1);
Updated:
textBox1.Text = string.Format("{0:N2}", Val1);
Yes - see here: https://msdn.microsoft.com/en-us/library/syy068tk(v=vs.90).aspx[^]
You need to select CultureInfo("hi-IN") IIRC
这篇关于如何格式化十进制数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文