Code Inspection: Possible 'System.InvalidOperationException'
Before you cast a variable of a nullable type to its underlying type, you should make sure that the value is not null. In the example below, we have a nullable double
x, and the expression
(double)x will throw an exception if
x is null.
JetBrains Rider suggests checking for null:
Alternatively, JetBrains Rider can add the assertion that the expression is not null: