Checks if an object is compatible with a given type.
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.
The is keyword causes a compile-time warning if the expression is known to always be
true or to always be false, but typically evaluates type compatibility at run time.
The is operator cannot be overloaded.
Note that the
is operator only considers reference conversions, boxing conversions, and unboxing conversions. Other conversions, such as user-defined conversions, are not considered.
Anonymous methods are not allowed on the left side of the
is operator. This exception includes lambda expressions.
时间: 2024-11-05 04:51:42