Skip to content

Instantly share code, notes, and snippets.

@scottheckel
Last active February 25, 2016 20:33
Show Gist options
  • Save scottheckel/7ad768d171e8f38022b4 to your computer and use it in GitHub Desktop.
Save scottheckel/7ad768d171e8f38022b4 to your computer and use it in GitHub Desktop.
yay/nay
public class Brulean
{
private string Value { get; set; } = "nay";
public static implicit operator bool(Brulean brul)
{
return brul.Value == "yay";
}
public static implicit operator Brulean(bool value)
{
return new Brulean { Value = value ? "yay" : "nay" };
}
public static implicit operator string(Brulean brul)
{
return brul.ToString();
}
public static implicit operator Brulean(string value)
{
return new Brulean { Value = value == "yay" ? "yay" : "nay" };
}
public override string ToString()
{
return Value;
}
}
@scottheckel
Copy link
Author

yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment