asp .net 中 判断值是否是数字

代码
    public static 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 @ 2010-03-23 13:42  韩天伟  阅读(658)  评论(1编辑  收藏  举报