In trying to convert an enumeration into an int[] of its values, I initially came up with the long-winded:
Enum.GetValues(typeof(Isolations.Enumerations.TypeSelectionScope))
.Cast<Isolations.Enumerations.TypeSelectionScope>().Select(t => (int)t).ToArray()
It works, but.. well, it ain't pretty.
I did some searching, and found people using ConvertAll() for this purpose, over multiple lines. So I tried it inline.
Array.ConvertAll(Enum.GetValues(typeof(Isolations.Enumerations.TypeSelectionScope)), value => (int)value)
This generates a type error, and adding some casting within is going to make it as messy as the first attempt.
I also tried a direct cast to an int[] to no avail:
Enum.GetValues(typeof(Isolations.Enumerations.TypeSelectionScope)).Cast<int[]>()
Adding a ToArray() onto this fails also.
So, what's a single-line solution to this that isn't messy?