Skip to content

Instantly share code, notes, and snippets.

@jaykz52
Created December 14, 2010 00:49
Show Gist options
  • Save jaykz52/739851 to your computer and use it in GitHub Desktop.
Save jaykz52/739851 to your computer and use it in GitHub Desktop.
An example of implementing the "typesafe enum" pattern in .NET
public class Suit
{
public static readonly Suit CLUBS = new Suit("Hearts");
public static readonly Suit DIAMONDS = new Suit("Diamonds");
public static readonly Suit HEARTS = new Suit("Hearts");
public static readonly Suit SPADES = new Suit("Spades");
private Suit(string pName)
{
name = pName;
}
private string name;
public string Name
{
get { return name; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment