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.
ReSharper suggests checking for null:
Alternatively, ReSharper can add the assertion that the expression is not null: