首页 > 代码库 > C# - is
C# - is
Checks if an object is compatible with a given type.
An is expression evaluates totrue 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 betrue 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 theis operator. This exception includes lambda expressions.
C# - is