数字格式转换,如何吧2178000.00转换未2,178,000.00,
我现在有个变量值未2178000.00,怎么样吧它转换未2,178,000.00

解决方案 »

  1.   

    不行啊,现在假设string strl="2178000.00",谁给个完整的
      

  2.   

    string strl="2178000.00";
    MessageBox.Show(System.Convert.ToDouble(strl).ToString("###,###,###.00"));
      

  3.   

    Decimal dec=2178000.00m;
    Console.Write(dec.ToString("###,###,##0.#0"));测试通过
      

  4.   

    keywords:tocurrency,
     pls reference msdn
      

  5.   

    Console.Write(dec.ToString("###,###,##0.#0"));
      

  6.   

    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;
    }
      

  7.   

    如果是数值可以 toString("N")吧