CSharp examples for Language Basics:Null Operator
The ?? operator is the null-coalescing operator.
If the operand is non-null, get its value; otherwise, get its default value.
For example:
using System;/*from ww w .j a va2 s. c om*/ class Test { static void Main(){ string s1 = null; string s2 = s1 ?? "nothing"; // s2 evaluates to "nothing" Console.WriteLine (s1); Console.WriteLine (s2); } }