I have a workflow that requires selecting three random numbers from 1-10 but the cannot be the same. I’m familiar with New Random().Next(1,10), but they are occasionally the same.
I’m thinking I can create an array the includes each number,
Generate random number between 1-10, select and remove that number from the array
Generate a random number between 1-9, select and remove that number from the array
Generate a random number between 1-8, select and remove that number from the array
So:
1,2,3,4,5,6,7,8,9,10
Generate random between 1-10: 6
6 is chosen
1,2,3,4,5,7,8,9,10
Generate random between 1-9: 6
7 is chosen
etc
A) how would I go about doing this?
B) this seems suboptimal. Is there a better way?