You can use the as operator to cast without raising an exception if the cast fails. The general form: expr as type expr is the expression being cast to type. On succeed, a reference to type is returned. Otherwise, a null reference is returned.