Skip to content

Casting with “as”

The as operator assigns null to a variable if the given object is not of the specied type (e.g. for o as string, o must be a string to get converted):

string s = o as string;


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.