怎样在C#中判断字符串为纯数字类型的?我需要返回bool类型的

解决方案 »

  1.   

    [/code]
    string message="123fd";
    int i=0;
       try
            {
              result = int.Parse(message);//这里如果转换不成功会抛错
                return true;
            }
            catch
            {
                return false;
            }
      

  2.   

    double num;
    if(double.TryParse(str,out num)){
    }
      

  3.   

    bool foundMatch = false;
    try {
    foundMatch = Regex.IsMatch(subjectString, @"^[+-]?\d+(.\d+)?$");
    } catch (ArgumentException ex) {
    // Syntax error in the regular expression
    }