When programming you will have to perform numerous NPE checks, in C# 6.0 Microsoft introduced monadic null checking.
Although this is already some time available, I just found out.
So instead of doing this:
if (points != null) {
var next = points.FirstOrDefault();
if (next != null && next.X !=null) {
return next.X;
}
}
return -1
You can do this:
return points?.FirstOrDefault()?.X ?? -1;
After some time you are really starting to like it.