Skip to content

Instantly share code, notes, and snippets.

@jbrestan
Created December 30, 2013 02:12
Show Gist options
  • Save jbrestan/8177003 to your computer and use it in GitHub Desktop.
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)
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