Microsoft Dot Net
Translate
Sunday, October 30, 2011
C# ?? operator (null coalescing operator)
int
? a=
null
;
//int? means a nullabe int. In other words an int variable that can be set to null
int
? b;
b = 5;
int
? c = a ?? b;
//This means pick a if it is not null, else pick b
Console
.WriteLine(c);
//Displays 5
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)