Use a cast instead of an 'as' check.