Posts filed under ‘c#’

Little-known C# 2.0 operator – ??

Excerpt from the msdn:

The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.

Example:

string s = null; 
int? i = null; 
Console.WriteLine(s ?? "(null)"); 
Console.WriteLine(i ?? -1);

Will produce:

(null) 
-1
Advertisements

August 21, 2007 at 2:39 pm 2 comments


Calendar

October 2017
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Posts by Month

Posts by Category