if(OBA is type)
{
}
type是个动态值 即不是具体的类型
这样写不行
如何实现动态匹配

解决方案 »

  1.   

    if(OBA is typeof(type))
    {
    }
      

  2.   


    string strType = "System.Int32";
    if(OBA is Type.GetType(strType ))
    {
    }
      

  3.   

    楼上两位,is 后面应该是类型而不是System.Type对象吧
      

  4.   

    string s = objArray[i] as string;
     if (o is Class1);.......
      

  5.   

    if ( obj1.GetType() == obj2.GetType() )
      

  6.   

    应该用这样的方式
    if(typeof(System.Int32).IsInstanceOfType(obj))
    如果直接用==比较的话,无法匹配基类
      

  7.   

    可能大家误解我的意思了
    我的意思是type是动态传入的值
    不是具体的类型值
      

  8.   

    动态传入的值到底是什么?
    是System.Type对象吗?
    if(OBA.GetType() is 此对象)
      

  9.   

    Type type=.....;
    if(type.IsInstanceOfType(obj))
    {
    ......
    }
      

  10.   

    if (OBA.GetType().Name == type.GetType().Name)