Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.
mr-ponna.com

 

YOU ARE HERE: HOME Questions What is difference between is and as operators in c



IS and AS operators in C#

View(s): 19594

What is difference between is and as operators in c#?

Answer 1)

The is operator checks whether an object is compatible with a given type, and the result of the evaluation is a Boolean: true or false. The is operator will never throw an exception.
An is expression evaluates to true if both of the following conditions are met: 
  • expression is not null
  • expression can be cast to type
The as operator is like a cast except that it yields null on conversion failure instead of raising an exception. More formally, an expression of the form:

Employee
e = obj as Employee;

is equivalent to:

Employee
e = obj is Employee ? (Employee)obj : (Employee)null;

  Asked in:  Mahindra Satyam   Expertise Level:  Intermediate
  Last updated on Friday, 10 February 2012
3/5 stars (13 vote(s))

Register Login Ask Us Write to Us Help