I have a enum containing the following (for example):
In my code I use
One other possibility that hasn't been mentioned is something like this:
public class Country
{
public static readonly Country UnitedKingdom = new Country("UK");
public static readonly Country UnitedStates = new Country("US");
public static readonly Country France = new Country("FR");
public static readonly Country Protugal = new Country("PT");
private Country(string shortName)
{
ShortName = shortName;
}
public string ShortName { get; private set; }
}
From this point you could add more properties, but beware of how much you add to the class, and how many static members you add, as the memory bloat it adds could make it not worth it.
I don't think there are many cases where this strategy is the best approach, but it is an option to be aware of when attempting to add properties or attributes to something you want to be able to treat as essentially an enum.