You can use the as operator to cast without raising an exception if the cast fails.
The general form:
expr as type