Can't make an array in C#
Posted
by Josh
on Stack Overflow
See other posts from Stack Overflow
or by Josh
Published on 2010-03-22T20:09:30Z
Indexed on
2010/03/22
20:11 UTC
Read the original article
Hit count: 451
I'm trying to make a dynamic array in C# but I get an annoying error message. Here's my code:
private void Form1_Load(object sender, EventArgs e)
{
int[] dataArray;
Random random = new Random();
for (int i = 0; i < random.Next(1, 10); i++)
{
dataArray[i] = random.Next(1, 1000);
}
}
And the error:
Use of unassigned local variable 'dataArray'
This is just baffling my mind. I came from VB, so please me gentle, lol.
Cheers.
© Stack Overflow or respective owner