How to get random values from array in C# [duplicate]

I use the random.next(0, array.length), but this give random number of the length and i need the random array numbers.

Use the return value from random.next(0, array.length) as index to get value from the array

 Random random = new Random();
 int start2 = random.Next(0, caminohormiga.Length);
 Console.Write(caminohormiga[start2]);

Leave a Comment