Question: I have an enum that I'd like to display all possible values of. Is there a way to get an array or list of all the possible values of the enum instead of manually creating such a list? e.g. If I have an enum:

```
public enum Enumnum { TypeA, TypeB, TypeC, TypeD }

```

how would I be able to get a `List<Enumnum>` that contains `{ TypeA, TypeB, TypeC, TypeD }`?

Answer: 
You may want to do like this:

```
public enum Enumnum { 
            TypeA = 11,
            TypeB = 22,
            TypeC = 33,
            TypeD = 44
        }

```

All int values of this `enum` is `11,22,33,44`.

You can get these values by this:

```
var enumsValues = Enum.GetValues(typeof(Enumnum)).Cast<Enumnum>().ToList().Select(e => (int)e);

```

`string.Join(",", enumsValues)` is `11,22,33,44`.
If you prefer a more generic way, here it is. You can add up more converters as per your need.

```
    public static class EnumConverter
    {

        public static string[] ToNameArray<T>()
        {
            return Enum.GetNames(typeof(T)).ToArray();
        }

        public static Array ToValueArray<T>()
        {
            return Enum.GetValues(typeof(T));
        }

        public static List<T> ToListOfValues<T>()
        {
            return Enum.GetValues(typeof(T)).Cast<T>().ToList();
        }

        public static IEnumerable<T> ToEnumerable<T>()
        {
            return (T[])Enum.GetValues(typeof(T));
        }

    }

```

Sample Implementations :

```
   string[] roles = EnumConverter.ToStringArray<ePermittedRoles>();
   List<ePermittedRoles> roles2 = EnumConverter.ToListOfValues<ePermittedRoles>();
   Array data = EnumConverter.ToValueArray<ePermittedRoles>();

```