When is obj.GetType().IsInstanceOfType(typeof(MyClass)) true?

后端 未结 5 936
终归单人心
终归单人心 2021-01-06 06:52

I\'m looking at this piece of code written by someone else, and I\'m wondering when it would evaluate to true. Basically, it is saying someType is an instance of someOtherT

5条回答
  •  清歌不尽
    2021-01-06 07:34

    IsInstanceOfType() checks whether the instance that you pass it is an instance of the type you called it on.

    You're passing a System.Type instance to IsInstanceOfType(). That will only be true if you call it on typeof(Type) or one of its base classes.

提交回复
热议问题