反射
Type t = a.GetType();
if (t is PointObject)
......
if( t is PolyLineObject)
......

解决方案 »

  1.   

    不对,我用你的方法得到a是System._ComObject,和PointObject是不等的。
      

  2.   

    You can try casting the object to a target type (believe me, CLR knows it's a COM object and will call QueryInterface instead):PointObject pt = a as PointObject;
    if (pt != null) {
       //it's a point object.
    } else {
       //it's not, try other types.
    }This will work in most cases.
    And also, you might want to try Marshal.CreateWrapperOfType:try {
       PointObject pt = (PointObject)Marshal.CreateWrapperOfType(a, typeof(PointObject));
    } catch (InvalidCastException e) {
      //not point object
    }