Skip to content

Instantly share code, notes, and snippets.

@juanplopes
Forked from jagregory/1 - StronglyTypedEnum.cs
Created February 12, 2011 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanplopes/823834 to your computer and use it in GitHub Desktop.
Save juanplopes/823834 to your computer and use it in GitHub Desktop.
public struct MyEnum
{
public static readonly MyEnum Value1 = new MyEnum("value1");
public static readonly MyEnum Value2 = new MyEnum("value2");
readonly string name;
MyEnum(string name) : this()
{
this.name = name;
}
}
public struct Country
{
public static readonly Country US = new Country("US", "United States", "USD");
public static readonly Country GB = new Country("GB", "Great Britain", "GBP");
public string CountryCode { get; private set; }
public string Description { get; private set; }
public string Currency { get; private set; }
Country(string countryCode, string description, string currency) : this()
{
CountryCode = countryCode;
Description = description;
Currency = currency;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment