Return to Snippet

Revision: 10462
at December 30, 2008 14:53 by mordecaix7


Initial Code
Nullable<int> x;

int y = x ?? -1;

Initial URL

                                

Initial Description
If you set the int keyword to be Nullable, then when x is declared there it's set to null.
On the second line, the "??" are saying if x is null then assign -1 instead.

Initial Title
Assign Default Value to Variable if Second Variable is Null

Initial Tags

                                

Initial Language
C#