Monday, March 05, 2012

is and as operators in C#


is Operator:
  • is operator 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.
as Operator:
  • The as operator is used to perform conversions between compatible reference types
  • The as operator is like a cast operation. However, if the conversion is not possible, as returns null instead of raising an exception

No comments:

Post a Comment