This post originated from an RSS feed registered with .NET Buzz
by Richard Jonas.
Original Post: C# COALESCE operator
Feed Title: Richard Jonas
Feed URL: http://feeds.feedburner.com/blogspot/ouNA
Feed Description: Richard Jonas's blog about .NET, web development and agile methodologies.
A useful function in T-SQL is COALESCE, which takes two arguments and returns the first if it is not null and the second if the first is null.
I found out today about a feature in C# 2.0 that I had somehow missed which does the same thing (via Avner Kashtan's blog).
String a = null;
String b = "abc";
String c = a ?? b;
returns "abc".
These can also be chained, so the first non-null argument