一种情况,如果不想让用户在文本框内输入数字类型的字符 在web上可能有很多的判断方法,在cs上我暂时能想到的是try,catch 可是这个效率很低 不想用 在网上找找~~~~~~~~~ 1using System.Text.RegularExpressions 2//引用命名空间 3 4string name=txtname.Text.Trim(); 5string ex=@"^\d*$"; 6Regex reg = new Regex(ex); 7if(reg.IsMatch(name)==true) 8); 我想这样比起我用try catch 效率要高点吧 ^_^ 相关文章: 2022-12-23 2021-08-04 2022-02-03 2021-12-16 2022-01-05 2022-12-23