I'm writing a program , that create a random numbers and moves to an array. This is my class called randomize:
class Randomize
{
public int[] _array;
public int[] Array{ get { return _array; } set { _array= value; } }
public Randomize(int[] array)
{
Array= array;
}
public int _min;
public int Min
{
get { return _min; }
set { _min = value; }
}
public int _max;
public int Max { get { return _max; } set { _max = value; } }
public Randomize(int min, int max)
{
Min = min;
Max = max;
}
public override string ToString()
{
return string.Format(Max.ToString(), Min.ToString());
}
public override string ToString()
{
return string.Format(Array.ToString());
}
Min and Max is MinValue and MaxValue.
And now my form:
private void button1_Click(object sender, EventArgs e)
{
Randomize min = new Randomize(0, 100);
Random rand= new Random(); // randomize
Randomize[] array= new Randomize[10];
for (int i = 0; i < array.Length; i++)
{
array[i] = rand.Next(0,100); //draw in loop
}
textBox1.Clear();
for (int i = 0; i < array.Length; i++)
{
textBox1.Text = textBox1.Text + " " + array[i].ToString(); //show in textbox
}
}
And my question is how can I request my array and random numbers to my button1.
Now i have error 'cannot implicitly convert type to int' in first FOR loop.
Thanks and regards :)
Randomizeand only provide the count and random limits to the constructor.