c# 字符串整形效验

来源:互联网 发布:最新版itunes更新软件 编辑:程序博客网 时间:2024/04/28 10:04
  public static Boolean intchk (string str)
    {
        string temp;
        Boolean a=false;
        if (str.Length <= 0)
        {
            MessageBox.Show("数据不能为空");
            return a ;
        }
        for (int i = 0; i <= str.Length - 1; i++)
        {
            temp = str.Substring(i, 1);
            if (Asc(temp) < 46 | Asc(temp) > 57)
            {
                //MessageBox.Show("数据不为数值型");
                a=false;
                break;
            }
            else
            {
                a=true;
            }
    
        }
       
        return a;
       // MessageBox.Show(temp);
    }