Skip to content

Instantly share code, notes, and snippets.

@tomwis
Last active August 19, 2017 15:11
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 tomwis/f74bba65d20293d21dbffdd6284655a7 to your computer and use it in GitHub Desktop.
Save tomwis/f74bba65d20293d21dbffdd6284655a7 to your computer and use it in GitHub Desktop.
string? x = ...; // może być nullem
string s = "hello"; // nie może być nullem
var s2 = b ? " world" : x; // s2 może być nullem
string s3 = s + s2; // błąd, nie użyć tutaj s2, które jest typu string?, wtedy s3 też musiałoby być tego typu
string s3 = s + (s2 ?? " you"); // tak będzie ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment