Last active
May 9, 2020 09:09
-
-
Save enisn/e594ae55bce80fba16432c9a77616d45 to your computer and use it in GitHub Desktop.
NullChecks - Sample 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
DoSomething("Hello World!"); // Works perfectly 👌 | |
DoSomething(null); // Throws ArgumentNullException at runtime. | |
string parameter = null; | |
DoSomething(parameter); // Throws ArgumentNullException at runtime. | |
} | |
public static void DoSomething(NotNull<string> message) // <--- NotNull is used here | |
{ | |
Console.WriteLine(message.Value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment