I have a enum containing the following (for example):
In my code I use
You could create an extension method public static string ToShortString(this Country country)
. In the method you could use either a static Dictionary as Jon suggests, or you could simply do a switch case.
Example:
public static class CountryExtensions
{
public static string ToShortString( this Country target )
{
switch (target) {
case Country.UnitedKingdom:
return "UK";
case Country.UnitedStates:
return "US";
case Country.France:
return "FR";
case Country.Portugal:
return "PT";
default:
return "None";
}
}
}