I am programming in C# and I want to define an array which I don't know it's size, because I want to read somethings from file and I don't know the number of elements in that file. This is my code, and I have problem with "x" array!
using (TextReader reader = File.OpenText("Numbers.txt"))
{
string[] bits;
string text = reader.ReadLine();
int i ,j=0;
int [] x;
while (text != null)
{
i = 0;
bits = text.Split(' ');
while (bits[i] != null)
{
x[j] = int.Parse(bits[i]);
i++;
j++;
}
text = reader.ReadLine();
}
}
and after that I will get this error "Use of unassigned local variable 'x'" I don't know what should I do!! Please help me...
Listand when you have all the elements and know the size, convert to array.