Skip to content

Instantly share code, notes, and snippets.

@OdeToCode
Created December 4, 2014 15:04
Show Gist options
  • Select an option

  • Save OdeToCode/1e688037c6d1fb7483fb to your computer and use it in GitHub Desktop.

Select an option

Save OdeToCode/1e688037c6d1fb7483fb to your computer and use it in GitHub Desktop.
// this:
var foo = "hi!";
var length = foo?.Length;
// will create this:
string str = "hi!";
int? nullable = str != null ? new int?(str.Length) : new int?();
// while this:
var foo = "hi!";
int length = foo?.Length;
// becomes this:
"Error CS0266 Cannot implicitly convert type 'int?' to 'int'. An explicit conversion exists (are you missing a cast?)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment