'as' operator

  • Thread starter Thread starter Guest
  • Start date Start date
"as" operator is also "explicit" casting. The difference is that the "as"
operator does not call user defined conversion operators and cannot be
applied to value types, thus "as" is faster than a cast.
"as" returns null if the cast of not valid whereas a direct cast throws an
invalidcastexception.
Which one you prefer depends on the specific situation.
 
Back
Top