EnumHelper.cs
// Copyright 2012 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // using System; using System.Collections.Generic; using System.Text; namespace Events { public class EnumUtils { public static List<T> EnumToList<T>() { Type enumType = typeof(T); // Can't use type constraints on value types, so have to do check like this if (enumType.BaseType != typeof(Enum)) { throw new ArgumentException("T must be of type System.Enum"); } return new List<T>(Enum.GetNames(enumType) as IEnumerable<T>); } } }