Working with the possibility of null in any language that allows tt is tedious, and there's boilerplate code involved, it's not fun and error prone.
Lets say we receive some value and it is null and we are going to use that in our code
- var divident=null;
- var value=divident /2;
Above line will throw a null exception.
To avoid that one might add a condition that could be:
- if(divident !=null)
- {
- var value=divident / 2;
- }
A better way could be like below:
- var value= (divident ?? 0) / 2;