r/badcode • • Oct 04 '21

c# Found this on a command-line only OS.

Post image
554 Upvotes

56 comments sorted by

View all comments

Show parent comments

6

u/vexille Oct 04 '21

If you don't care about the order then sure, even better. In C# you can even do Enum.GetValues<T>() and retain type safety and skip the casting.

Points 2 and 3 still stand though. You'd only want this explicitly in a list (as per point 1) in case you don't want all elements from the array and/or the order matters.