The preceding code will not fail nor throw any exceptions. It will just return the null value instead. Our casting test code is going to print the following output to the console:
null
8.802117014997226
null
Using the safe as? casting modifier is a neat alternative to the traditional way. You can use it if you are working with nullable types, that is while working with external libraries that don't provide the null safety. However, if you can benefit from the null safety, it's best to use the standard casting operation.