I have the enum structure as follows:
public enum MyEnum
{
One=1,
Two=2,
Three=3
}
Now I want to get a list of MyEnum
, i.e., List<MyEnum>
that contains all the One
, Two
Three
. Again, I am looking for a one liner that does the thing. I came out with a LINQ query but it was unsatisfactory because it was a bit too long, I think:
Enum.GetNames(typeof(MyEnum))
.Select(exEnum =>
(MyEnum)Enum.Parse(typeof(MyEnum), exEnum))
.ToList();
A better suggestion?