// just some quick snippets for GUI / Winforms / C# / etc // these might not be the best ways to do this stuff, was just working on some ideas // example of an enum with Description() applied public enum ROMMapMode : byte { LoROM, HiROM, ExHiROM, [Description("SA - 1 ROM")] SA1ROM, [Description("SA-1 ROM (FuSoYa's 8MB mapper)")] ExSA1ROM, SuperFX, [Description("Super MMC")] SuperMMC, ExLoROM } // take a enum type that has [Description] attributes, // return a List with with kvp pairs of enum vs description public static List> GetEnumDescriptions() where TEnum : Enum { var type = typeof(TEnum); return Enum.GetValues(type) .Cast() .Select(value => new KeyValuePair(key: value, value: GetEnumDescription(value)) ) .OrderBy(item => item.Key) .ToList(); } public class EnumMapper where TEnum : Enum { public TEnum Source { get; set; } // surely... there is some third party library that handles this. // for now, here we are. public int SelectedIndex { get => Convert.ToInt32(Source); set => Source = (TEnum)Enum.ToObject(typeof(TEnum), value); } public List> Descriptions { get; } = Util.GetEnumDescriptions(); } var mapper = new EnumMapper();