?? operator
Posted on September 24, 2007
I just discovered a new Operator in .Net 2.0…
the ?? operator.
One of the most anoing things to do when retrieving data, is checking for null values:
string myValue = dataReader.IsDBNull(2) ? string.Empty : dataReader.GetString(2);
But the ?? operator makes it a lot easier:
string myValue = dataReader.GetString(2)??string.Empty;
Why didn’t anybody tell me about this before?????
Read more here : http://msdn2.microsoft.com/en-us/library/ms173224(VS.80).aspx