当前位置: 代码迷 >> ASP.NET >> 急货币格式化(还原)有关问题
  详细解决方案

急货币格式化(还原)有关问题

热度:5470   发布时间:2013-02-26 00:00:00.0
急~货币格式化(还原)问题
有一decimal型变量,应需要把它转换成¥33.00的string类型,后应需要想把¥33.00转回33.00的形式,类似
        class   Class1
        {

                static   void   Main()
                {
                        decimal   a   =   33;
                        Console.Write(a.ToString( "C "));
                        string   b   =   a.ToString( "C ");
                        decimal   c   =   Convert.ToDecimal(b);//出错
                        Console.Write(c.ToString());
                        Console.ReadKey();
                }
        }
各位大虾帮帮忙

------解决方案--------------------------------------------------------
直接去掉第一个字符好了
------解决方案--------------------------------------------------------
同意思楼上,,直接用个函数去掉就行了
------解决方案--------------------------------------------------------
decimal c = Convert.ToDecimal(b.Replace( "¥ ", " "));
------解决方案--------------------------------------------------------
decimal a = 33;
Console.Write(a.ToString( "C "));
string b = a.ToString( "N ");
decimal c = Convert.ToDecimal(b);
Console.Write(c.ToString());
------解决方案--------------------------------------------------------
  相关解决方案