how can i random numbers without repetition untill all the numbers are loaded? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

how can i random numbers without repetition untill all the numbers are loaded?

i am using array and not list.

16th Aug 2016, 2:45 PM
Warren Caraig
Warren Caraig - avatar
2 Answers
+ 1
you'll need an if statement to check whether the array already contains the generated random number. Be careful when generating random numbers not to keep creating new random object. the initial one can be reused.
11th Nov 2016, 12:20 AM
Stuart
Stuart - avatar
- 1
you can use the class Random : Random r =new Random(min,max) ; int val = r.Next()//pick a new number
23rd Aug 2016, 8:15 AM
Geoffrey Haon
Geoffrey Haon - avatar