.net编程时 判断是否输入为数字
2014-11-18 15:24
162 查看
第一种方法:正则表达式<span style="white-space:pre"> </span>Regex numRegex = new Regex(@"^\d+$"); string id = Request.QueryString["Id"]; if (numRegex.IsMatch(id)) { // id 为纯数字。。 } else { // id 包含数字以外的字符。。 }
第二种方法:
try catch方法 例:try { Convert.ToInt32("123"): Console.Write("是数字"); } catch(Exception ex) { Console.Write("非数字"); }第三种方法:
Information.IsNumeric(txt_num.Text.Trim());
但是Information在4.5中貌似没有。
但部分书上有这么写。
等有准确的消息在来修改。
相关文章推荐
- 判断输入的是否是数字函數
- 判断输入的是否是数字函數
- javascript 判断输入的数字是否int型
- javascript+正则表达式 判断输入的是否是数字
- 判断输入的内容是否为数字
- *判断输入是否是数字*
- java算法程序题,输入三个数求哪个是最大数,先判断这三个数是否整数,不是就打印提示:请输入数字,若是就打印出那个最大数
- 判断输入的字符是否是数字
- 判断输入的是否是数字函數
- 判断输入字符串是否是数字类型
- 判断输入是否为数字的最简单的方法(用JavaScript的正值表达式)
- 判断文本框输入是否为数字
- [Tool]判断用户输入是否符合规范(大小写0~9数字)
- javascript判断输入是否为数字
- js如何判断输入是否为正整数、浮点数等数字的函数
- C#(用函数判断输入的值是否是数字)[转载]
- javascript判断输入内容是否全部是数字
- javascript 判断 输入字符串 是否为 数字
- 使用NumberFormatter判断TextInput输入内容是否为数字,如果是则格式化数字。
- js如何判断输入是否为正整数、浮点数等数字的函数