C#判断是否是数字 @阿良.NET

来源:百度文库 编辑:神马文学网 时间:2024/07/08 10:45:25
C#判断是否是数字
.复制  保存
/// /// 判断是否是数字/// /// 字符串/// 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;}