Skip to content

Instantly share code, notes, and snippets.

@MelbourneDeveloper
Created February 13, 2021 08:37
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 MelbourneDeveloper/37b915b8d55c79de149f37e06e691960 to your computer and use it in GitHub Desktop.
Save MelbourneDeveloper/37b915b8d55c79de149f37e06e691960 to your computer and use it in GitHub Desktop.
Null Guard Example
#nullable enable
using System;
namespace Sample
{
public class NullGuardExample
{
public string NotNullableProperty { get; }
public string? NullableProperty { get; }
public NullGuardExample(
string notNullableProperty,
string? nullableProperty)
{
NotNullableProperty = notNullableProperty ?? throw new ArgumentNullException(nameof(notNullableProperty));
NullableProperty = nullableProperty;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment