bool bl = System.Text.RegularExpressions.Regex.IsMatch(name, @"[\u4e00-\u9fa5]+$");
if (!bl)
{
("姓名只能为汉字");
}
private static bool IsNumeric(string str) //接收一个string类型的参数,保存到str里
{
if (str == null || str.Length == 0) //验证这个参数是否为空
return false; //是,就返回False
ASCIIEncoding ascii = new ASCIIEncoding();//new ASCIIEncoding 的实例
byte[] bytestr = ascii.GetBytes(str); //把string类型的参数保存到数组里
foreach (byte c in bytestr) //遍历这个数组里的内容
{
if (c < 48 || c > 57) //判断是否为数字
{
return false; //不是,就返回False
}
}
return true; //是,就返回True
}