Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created August 23, 2015 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/efb71ecad94d92175778 to your computer and use it in GitHub Desktop.
Save angelovstanton/efb71ecad94d92175778 to your computer and use it in GitHub Desktop.
int? x = null;
int y = x ?? -1;
Console.WriteLine("y now equals -1 because x was null => {0}", y);
int i = DefaultValueOperatorTest.GetNullableInt() ?? default(int);
Console.WriteLine("i equals now 0 because GetNullableInt() returned null => {0}", i);
string s = DefaultValueOperatorTest.GetStringValue();
Console.WriteLine("Returns 'Unspecified' because s is null => {0}", s ?? "Unspecified");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment