Created
December 30, 2013 02:12
-
-
Save jbrestan/8177003 to your computer and use it in GitHub Desktop.
Wrapper for primitive and sealed types to be used where more specific meaning of the primitive/sealed type is desired (and could otherwise be solved with a subtype)
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 abstract class TypeSafetyWrapper<T> | |
{ | |
private readonly T value; | |
public TypeSafetyWrapper(T value) | |
{ | |
this.value = value; | |
} | |
public T Value { get { return value; } } | |
public override string ToString() | |
{ | |
return value.ToString(); | |
} | |
public static implicit operator T(TypeSafetyWrapper<T> wrapper) | |
{ | |
return wrapper.Value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment