判断是否为数字

来源:互联网 发布:ubuntu去掉标题栏 编辑:程序博客网 时间:2024/05/24 15:43
  private bool IsNumeric(string str)    {        if (str == null || str.Length == 0)            return false;        System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();        byte[] bytestr = ascii.GetBytes(str);        foreach (byte c in bytestr)        {            if (c < 48 || c > 57)            {                return false;            }        }        return true;    }

0 0
原创粉丝点击