Given an arbitrary enumeration in C#, how do I select a random value?
(I did not find this very basic question on SO. I\'ll post my answer in a minute as reference f
You could just do this:
var rnd = new Random(); return (MyEnum) rnd.Next(Enum.GetNames(typeof(MyEnum)).Length);
No need to store arrays