DEV Community

Discussion on: C# - Asserting a value is not null in null-aware code

Collapse
 
mburszley profile image
Maximilian Burszley

The whole point of nullable references is being explicit and you're writing APIs as if the feature isn't enabled.

Collapse
 
bjorg profile image
Steve Bjorg • Edited

Thanks for highlighting the fact that I didn't make the motivation clear for this. I'm not a fan of the null forgiving operator (!), because it's hard to track down. Using AssertIsNotNull() achieves the same outcome and it's easier to find.