数字格式转换,如何吧2178000.00转换未2,178,000.00 数字格式转换,如何吧2178000.00转换未2,178,000.00,我现在有个变量值未2178000.00,怎么样吧它转换未2,178,000.00 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不行啊,现在假设string strl="2178000.00",谁给个完整的 string strl="2178000.00";MessageBox.Show(System.Convert.ToDouble(strl).ToString("###,###,###.00")); Decimal dec=2178000.00m;Console.Write(dec.ToString("###,###,##0.#0"));测试通过 keywords:tocurrency, pls reference msdn Console.Write(dec.ToString("###,###,##0.#0")); string strTextBox1; strTextBox1 = this.textBox1.Text; string strTemp; strTemp = ""; int intNum = strTextBox1.Length; //总数小于3 if(intNum <= 3) { strTemp = strTextBox1; } else { //如果总数是3的倍数,则基数等于3 intNum %= 3; if(intNum == 0) { intNum = 3; } //i要求值为被3整除后+1 for(int i = 0; i < strTextBox1.Length / 3 + 1 ; i++) { //第一次取从开始到个数为基数的字符 if(i==0) { strTemp += strTextBox1.Substring( 0 ,intNum ); strTemp += ",";} else { //保证不超出字符串总长度 if(intNum <strTextBox1.Length) { strTemp += strTextBox1.Substring( intNum ,3 ); strTemp += ","; intNum += 3; } } } } //因为最后多了一个",",所以要把最后眼一位除掉 strTemp=strTemp.Substring(0,strTemp.Length-1); this.textBox2.Text = strTemp; } 如果是数值可以 toString("N")吧 大侠帮忙 C# 怎么将jpg转换成RMVB或者是MP4格式 在线等!!! js获取textbox文本值的问题 .NET写入XML的问题 c# 中dataGridView 如何实现行行的拖动,即行之间相互交换位置 关于网络编程的问题? 设计器加载程序未提供类型解析服务,此服务是进行 CodeDom 序列化所必需的 关于listbox查询问题 我想为一个关于图像处理的问题 各位帮忙!一个奇怪的问题! 大家讨论一下,用c#写桌面或c/s程序与VB,DElphi,Pb,VC相比孰优孰劣?参与就散分 dataGrid某个单元格的值为0时,如何显示为“”或者空。 无需动脑!!就可得20分的问题!!
MessageBox.Show(System.Convert.ToDouble(strl).ToString("###,###,###.00"));
Console.Write(dec.ToString("###,###,##0.#0"));测试通过
pls reference msdn
strTextBox1 = this.textBox1.Text;
string strTemp;
strTemp = "";
int intNum = strTextBox1.Length; //总数小于3
if(intNum <= 3)
{
strTemp = strTextBox1;
}
else
{
//如果总数是3的倍数,则基数等于3
intNum %= 3;
if(intNum == 0)
{
intNum = 3;
}
//i要求值为被3整除后+1
for(int i = 0; i < strTextBox1.Length / 3 + 1 ; i++)
{
//第一次取从开始到个数为基数的字符
if(i==0)
{
strTemp += strTextBox1.Substring( 0 ,intNum );
strTemp += ",";}
else
{
//保证不超出字符串总长度
if(intNum <strTextBox1.Length)
{
strTemp += strTextBox1.Substring( intNum ,3 );
strTemp += ",";
intNum += 3;
}
}
} }
//因为最后多了一个",",所以要把最后眼一位除掉
strTemp=strTemp.Substring(0,strTemp.Length-1);
this.textBox2.Text = strTemp;
}