I'm trying to make a generic function that converts a enum System.Array into a List of those enums, I can not know the type of the enum array. I have tried several ways but I have not been able to make it work. It would be something like this..., Thanks
public static List<T> SArrayEnumToList<T>(System.Array arr){
Type enumType = typeof(T);
if(enumType.BaseType != typeof(Enum))
throw new ArgumentException("T must be of type System.Enum");
List<T> enumList = new List<T>(new T[arr.Length]);
int i;
for(i=0;i<arr.Length;i++) {
enumList.Add(( T )Enum.Parse(enumType, arr.GetValue(i).ToString()));
}
return enumList;
}