-
With C# 11, we finally get a syntax for non-nullable parameters (is that the right term?) that lets us do away with explicit My question is about those two exclamation marks. Why isn't it |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
A non nullable parameter is simply |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I would use the term null-checked parameters instead. |
Beta Was this translation helpful? Give feedback.
A non nullable parameter is simply
Type paramName
in nullable aware code. WithType paramName!!
you get a non nullable parameter with an explicit runtime check (a potential nullable violation causes just a warning which can be ignored or suppressed).This can be used for example for your public API which wants to enforce non null values for certain parameters. If your API might be used in a non-nullable aware environment you can avoid issues based on contract violations with this feature.