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