jeudi 13 juillet 2017

C# Random from array [duplicate]

This question already has an answer here:

Random rnd = new Random();
String[] ColorArray= { "Red", "Blue", "Green" };
return ColorArray[rnd.Next(ColorArray.Count())]; 

I want this to return a random color from the array. 100% of the time I get "Red" returned. I have no idea why. Any help?




Aucun commentaire:

Enregistrer un commentaire