Making a random array of integers
Hi,
Yesterday I switched from Delphi to C# and I'm very unfamiliar with it's syntax and all. So, I wanted to make a program which produces an array of 100 random integers, and then writes them down in a listbox.
Well I somehow managed to make this code, with lots of googling about how to generate random numbers, delaring arrays, loops etc.
The problem is, my program just generates 2 numbers, and repeats them. Please help me, I know this is a very newb question, but I'm so ........ed off about it, can't find what's wrong.
And the random function really sux in c# :S
Here is the code:
Code:
private void button1_Click(object sender, EventArgs e)
{
int [] niz = new int[100];
for (int i = 0; i < 100; i++)
{
Random m = new Random();
int ZOMG = m.Next(0,100);
niz[i] = ZOMG;
listBox1.Items.Add(Convert.ToString(ZOMG));
i = i + 1;
}
}