Skip to content

Instantly share code, notes, and snippets.

@enisn
Created May 8, 2020 21:19
Show Gist options
  • Save enisn/5b3740c1a91572ee99b1107d35ec2373 to your computer and use it in GitHub Desktop.
Save enisn/5b3740c1a91572ee99b1107d35ec2373 to your computer and use it in GitHub Desktop.
NullChecks - Sample 3
public class NotNull<T>
{
public NotNull(T value)
{
this.Value = value;
}
public T Value { get; set; }
public static implicit operator NotNull<T>(T value)
{
if (value == null)
throw new ArgumentNullException();
return new NotNull<T>(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment