I have searched this for hours and I'm not getting it. I don't seem to know how to return values using Fisher-Yates and many ways listed. I'm dying here.
I can get a RandomNumber, but this is reused over and over. I need it to be unique everytime when returned (or so I tend to think is possible).
I need help understanding what I should do, why each part does, and stuff for dummies. This is what works:
private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
And this is what I'm putting it into and it working (but not unique random numbers are used)... I only included what I felt needed to be looked at and where it is positioned:
private void ComputersTurn()
{
Control.ControlCollection coll = this.Controls;
foreach (Control c in coll)
{
if (...)
{
if (...)
{
if (...)
{
if ((c.Name == "btn" + Convert.ToString(RandomNumber(1,9)) && (c.Enabled != false) ))
{
if (...)
{
//code here
}
}
}
}
}
}
}
Again, RandomNumber works...but it's not unique. I wish to learn how to return a unique number (if possible).