Decimal temp = system.convert.ToDecimal(String);

解决方案 »

  1.   

    temp = system.convert.ToDecimal("0A")没问题吗?
    好像value只能是数字[+小数点+数字]
      

  2.   

    使用 temp = system.convert.ToDecimal("0A") 没有问题???
    我这里有问题!!!!
      

  3.   

    我的程序:
    using System;
    using System.Collections;
    class MonitorSample
     {
    static void Main(string[] args)
    {
    string input="";
    do{
    try{
    input=Console.ReadLine();
    Console.WriteLine("{0} parsed : {1}",input,System.Convert.ToDecimal(input));
    }
    catch
    {
    Console.WriteLine("格式错误");
    }
    }
    while(input.Length>0);
    }
    }
    运行结果:
    wo
    格式错误
    12,
    12, parsed : 12
    123,123123
    123,123123 parsed : 123123123
    123,12,123,123123,123
    123,12,123,123123,123 parsed : 12312123123123123
    3,3,3,3
    3,3,3,3 parsed : 3333
    3.1234567901234567890123456789
    3.1234567901234567890123456789 parsed : 3.1234567901234567890123456789
    0a
    格式错误
    oa
    格式错误
    1a
    格式错误
    1A
    格式错误
      

  4.   

    对了, temp 是 声明成 Decimal 的
      

  5.   

    Decimal.Parse("1A",System.Globalization.NumberStyles.AllowHexSpecifier);