Skip to content

Instantly share code, notes, and snippets.

@btjake
Last active August 29, 2015 14:04
Show Gist options
  • Save btjake/81c825ff437ff3e1196e to your computer and use it in GitHub Desktop.
Save btjake/81c825ff437ff3e1196e to your computer and use it in GitHub Desktop.
a wrapper that can never be null
public struct NotNull<T>
{
private T _value;
public T Value {
get
{
return _value;
}
set
{
if(value == null)
{
throw new ArgumentNullException("value can never be null");
}
_value = value;
}
}
public NotNull(T value)
{
if(value == null)
{
throw new ArgumentNullException("value can never be null");
}
_value = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment