Created
December 14, 2010 00:49
-
-
Save jaykz52/739851 to your computer and use it in GitHub Desktop.
An example of implementing the "typesafe enum" pattern in .NET
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 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