Lazy instantiation one-liner of instance fields with the coalesce operator
It is hardly worth blogging, but…
Did you know that the return value of an assignment is the assignment? i.e.
And did you know there is a coalesce operator since .NET 2.0 that will return the left-hand side if not null, or the right-hand side if the left-hand is null?
If you combine these information snippets you get the modern one-liner for lazy instantiation of instance fields: