这两者的确切区别是什么?
// When calling this method with GetByType<MyClass>()
public bool GetByType<T>() {
// this returns true:
return typeof(T).Equals(typeof(MyClass));
// this returns false:
return typeof(T) is MyClass;
}
typeof(AClass).IsAssignableFrom(typeof(T))
来解决这个问题。请参考 http://msdn.microsoft.com/en-us/library/system.type.isassignablefrom.aspx。 - Will