+ 1

Filling an array with random numbers

I filled an array with random numbers but I can't figure out any way to make it so that each number comes out just once. Has anybody got a solution to do that with c# ?

25th Sep 2017, 5:22 AM
Tho5mas
11 ответов
+ 9
This code generates an array of 10 random numbers i.e. 0 to 9 in any random order. Let me know whether this is what you are looking at- https://code.sololearn.com/cMCL8uNxF5l6/?ref=app
25th Sep 2017, 6:13 AM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 6
@Tho5mas you're welcome! 😇 @luka you did the same thing of getting distinct numbers. Only difference, you are not printing it😅
25th Sep 2017, 6:45 AM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 2
you can use bool arrayName.Contains(value)
25th Sep 2017, 5:51 AM
nuprivet
nuprivet - avatar
+ 2
Thanks a bunch! I'll try these.
25th Sep 2017, 6:14 AM
Tho5mas
+ 2
All my thanks to Apoorva and Luka. You helped me a lot. I can't believe I racked my brain and tried for hours to do that with conditions.
25th Sep 2017, 6:36 AM
Tho5mas
+ 1
@Gordie. Thanks a lot for your explanations, it's crystal clear and helped a great deal!
25th Sep 2017, 2:02 PM
Tho5mas
0
@Gordie. Fair enough, your answer shall then be the second best:)
25th Sep 2017, 2:13 PM
Tho5mas