I have two same enums that have the same names of members, but they are in different namespaces so they are "different types", but in fact namespace1.enum1 {a,b,c,d,e,f} and namespace2.enum2 {a,b,c,d,e,f}
How is the easiest way to convert IEnumerable<enum1>
to List<enum2>
without using loops?
Well something's going to loop somewhere, but it doesn't have to be in your code. Just a LINQ Select
will be fine:
var result = original.Select(x => (Enum2) x).ToList();
See more on this question at Stackoverflow