'as' operator

C

cody

"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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top