Seems like Dialog results return a nullable boolean (bool?), so whenever using a return dialog, you should take care of the null option (which I'm yet waiting to see happening ... ).
The above code (VS2012, Resharper 8), suggests that the left operand is never null. Any ideas why?
bool? dlg_result = some_window.ShowDialog();
bool some_bool = !dlg_result ?? true; // Resharper suggests this won't happen.
Here's a screenshot, easier to see:
Edit:
I've had a look in the resharper files, and it seems like ShowDialog
won't be null when using it from CommonDialog
and the Control
, but it might be null when using it from Window
. Attaching screenshot.
Will have to dig a bit deeper it seems, since I'm not sure which one I'm using.