Given an enum like this:
public enum City {
London = 1,
Liverpool = 20,
Leeds = 25
}
public enum House {
OneFloor = 1,
TwoF
This function might help you:
public static IEnumerable> GetValues() where T : struct
{
var t = typeof(T);
if(!t.IsEnum)
throw new ArgumentException("Not an enum type");
return Enum.GetValues(t).Cast().Select (x =>
new KeyValuePair(
(int)Enum.ToObject(t, x),
x.ToString()));
}
Usage:
var values = GetValues();