您的位置:首页 > 其它

判断是否是数字

2008-02-14 17:03 190 查看
1 private bool IsNumeric(string str)

7 {

8 if (str == null || str.Length == 0)

9 return false;

10 System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();

11 byte[] bytestr = ascii.GetBytes(str);

12 foreach (byte c in bytestr)

13 {

14 if (c < 48 || c > 57)

15 {

16 return false;

17 }

18 }

19 return true;

20 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: