我不知道有这样的函数
我一般这样做:
try
{
    int temp=Convert.ToInt16(str);
}
catch
{
    //不是
}
把这个写成函数放在公共类里面

解决方案 »

  1.   

    好像没有,
    我一般会自己写一个函数来判断
    public bool IsInt(sting strVal)
    {
    bool valid=true;
    try
     {
      int intVal = int.Parse(strVal);
     }
    catch
     {
      valid= false;
     }return valid;
    }
      

  2.   

    ???
    我刚写好,这么楼上已经有了,我可没抄袭阿,hehe
      

  3.   

    bool IsNumeric(string str){
         return Regex.IsMatch(str,@"^-?\d+(\.\d)?$");
         }
         void Page_Load() {
         Response.Write(IsNumeric("-1.2"));
         Response.Write(IsNumeric("1"));
         Response.Write(IsNumeric("a"));
         Response.Write(IsNumeric("1.2"));
         Response.Write(IsNumeric("1."));
         }