Skip to content

Instantly share code, notes, and snippets.

@enisn
Last active May 9, 2020 09:09
Show Gist options
  • Save enisn/e594ae55bce80fba16432c9a77616d45 to your computer and use it in GitHub Desktop.
Save enisn/e594ae55bce80fba16432c9a77616d45 to your computer and use it in GitHub Desktop.
NullChecks - Sample 5
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