KingAmu'Code

检测是否为数字的方法

    public 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;
    } 

方法一:

 

posted on 2010-03-18 17:35  阿牧  阅读(154)  评论(0编辑  收藏  举报

导航