The C# ?? null coalescing operator (and using it with LINQ) – ScottGu's Blog

Qualche giorno fa, parlavo su questo blog dell’operatore ?? di C#. Oggi, ScottGu fa, sul sui blog, un semplice esempio di utilizzo in LINQ:

One of the subtle (but cool) language features of C# is the ?? “null coalescing” operator.  This provides a nice, terse way to check whether a value is null, and if so return an alternate value.

Simple Example Usages

Several folks have blogged about the ?? operator in the past – read here, here, here, and here for some previous examples on how to use it.  Simply put, the ?? operator checks whether the value provided on the left side of the expression is null, and if so it returns an alternate value indicated by the right side of the expression.  If the value provided on the left side of the expression isn’t null, then it returns the original value…

Continua alla fonte: The C# ?? null coalescing operator (and using it with LINQ) – ScottGu’s Blog

Tags: