由于工作需要,在开发项目中对于一些经常用的函数,特总结如下:
一、判断是否为数字类型:
比如在网站中开发中常见的在传某个ID的时候,为了判断它是否是数字,就可以用下面这个函数
#region 判断是否为数字的函数 public static bool IsNumber(string TextValue) { try { int n = Convert.ToInt32(TextValue); return true; } catch { return false; } }#endregion//运用 if (!IsNumber(Request.QueryString["ID"])) { //输出错误 } else { //执行代码 }