Skip to content

Instantly share code, notes, and snippets.

@christiannagel
Created June 14, 2018 06:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save christiannagel/a25066cfd4157317d442c53e3f401d37 to your computer and use it in GitHub Desktop.
Using old and new libraries from C# 8 applications
var newglory = new NewAndGlory();
string? s1 = newglory.GetANullString();
string s2 = newglory.GetAString();
// string s3 = newglory.PassAString(null); // error: cannot convert null literal to non-nullable reference or unconstrained type parameter
var old = new Legacy();
string s4 = old.GetANullString(); // no error, s1 is null!
string s5 = old.PassAString(null); // no error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment