Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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