Created
February 13, 2021 08:37
-
-
Save MelbourneDeveloper/37b915b8d55c79de149f37e06e691960 to your computer and use it in GitHub Desktop.
Null Guard Example
This file contains 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
#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