Last active
August 29, 2015 14:04
-
-
Save btjake/81c825ff437ff3e1196e to your computer and use it in GitHub Desktop.
a wrapper that can never be null
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
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