没有这种方法你可以
try
{
  Convert.ToInt32();
}
catch
{
  ..
}
用这中方式来验证是否是合法的值类型

解决方案 »

  1.   

    try it:public bool IsInt(object obj){
        return(obj is System.Int32);
    }
      

  2.   

    哪有那么麻烦呀!
        Object 有现成的 Object.GetType() !!!!!!!!
        for example:
                 string  ss = "hello";
                 ss.GetType() //  result is "System.String";
    -------------------------------------------------------------
        
    另外,提醒各位小心使用 try{}catch{} ,性能的影响是相当大的!!!
      

  3.   

    如果你是指vb 的 IsNumeric 类似的是否可转换为目标类型的函数 那c# 是没有那东东的
      

  4.   

    example:
    public static bool IsNumeric(object value) 

       try 
       {
              int i = Convert.ToInt32(value.ToString()); 
              return true; 
        } 
        catch(FormatException) 
        { 
               return false; 
         }
    }
      

  5.   

    public static bool IsDateTime(object value) 

       try 
       {
              int i = Convert.ToDateTime(value.ToString()); 
              return true; 
        } 
        catch
        { 
               return false; 
         }
    }
      

  6.   

    不好意思,写错了
    public static bool IsDateTime(object value) 

       try 
       {
              DateTime DT = Convert.ToDateTime(value.ToString()); 
              return true; 
        } 
        catch
        { 
               return false; 
         }
    }
      

  7.   

    IsDateTime(),IsInt()
    等这样的函数要另外写才成。
    正如上面的兄弟们一样,几乎这些IS函数都是这样实现的。。
      

  8.   

    同意 erictang2003() ,这种方法才是正途。
      

  9.   

    try{
      DataTime.Parse(String);
    }catch(Exception ex){
      Response.Write(ex.Message);
    }
      

  10.   

    应该用Convert转换吧,或者最简单就是Try...catch