I started a new Interview Questions Blog where I will be posting solutions to commonly asked technical programming interview questions. Currently I have about 50 coding questions asked in programming interviews. Hopefully, I will be adding more questions and solutions progressively.
Archive for November, 2009
Technical programming interview questions blog
November 10th, 2009The C# Coalesce (??) Operator
November 10th, 2009The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.
if (myObject == null)
{
myObject = new MyClass();
}
return myObject;
The above code can be represented using the one-liner below.
return myObject ?? new MyClass();