C# - is



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.

posted @ 2015-06-23 13:42  phlsheji  阅读(136)  评论(0编辑  收藏  举报