C# casting vesus as operator

This is msdn explanation on it link

Put it in a simple way : The as operator is like a cast except that it yields null on conversion failure instead of raising an exception.

but it can only perform reference conversions and boxing conversions.

others like user-defined conversions should use casting. if you use ‘as’, it will return null.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s