What is the C# equivalent to Java's isInstance()?

前端 未结 5 935
清歌不尽
清歌不尽 2020-12-13 16:54

I know of is and as for instanceof, but what about the reflective isInstance() method?

5条回答
  •  清歌不尽
    2020-12-13 17:12

    Below code can be alternative to IsAssignableFrom.

    parentObject.GetType().IsInstanceOfType(inheritedObject)
    

    See Type.IsInstanceOfType description in MSDN.

提交回复
热议问题