string name = tb_name.Text; 如何判断name里面是否包含数字。。各位大虾。速来!

解决方案 »

  1.   


      public bool IsNumeric(string s, out double result)
    {
       bool bReturn = true;
       try
       {
            result = double.Parse(s);
       }
       catch
       {
            result = 0;
           bReturn = false;
       }
       return bReturn;      
    }
      

  2.   

    string name = "sadj2837s";
                Console.WriteLine(System.Text.RegularExpressions.Regex.IsMatch(name,"[0-9]+"));
      

  3.   

     public bool IsNumeric(string s, out double result)
    {
       bool bReturn = true;
       try
       {
            result = double.Parse(s);
       }
       catch
       {
            result = 0;
           bReturn = false;
       }
       return bReturn;      
    }
      

  4.   


    这个绝对不行。2323abd 这样的呢??
      

  5.   

    int.TryParse("",out i);
    if(Regex.IsMatch("",@ "^[0-9]+$ "))
    {
    }