C# 'is' operator Clarification

前端 未结 6 1971
半阙折子戏
半阙折子戏 2021-01-17 21:11

Does the is operator indicate whether or not an object is an instance of a certain class, or only if it can be casted to that

6条回答
  •  遇见更好的自我
    2021-01-17 21:28

    An is expression evaluates to true if the provided expression is non-null, and the provided object can be cast to the provided type without causing an exception to be thrown.

    Source

提交回复
热议问题