@r ht , if you want to make the member of the array between 0 and 2, please use test[i] = rand.Next(0,3);
As the Microsoft doc said:
The Next(Int32, Int32) overload returns random integers that range from minValue to maxValue - 1. However, if maxValue equals minValue, the method returns minValue.
You can find the sentence from the doc Random.Next Method.
If the response is helpful, please click "Accept Answer" and upvote it.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.