I'm trying to make this program where a user will input a number in a textbox and it will store it into an array.
So whenever the user clicks "calculate", it will get an average of all the numbers in the array. For some reason, when I try to run it, I get:
Additional information: Object reference not set to an instance of an object.
But then I can't initialize the array to specific length because I don't know how many numbers the user will input. So I was wondering is there a way to make it work without initializing a specific length for the array?
double[] numArray;
int count=0;
private void button1_Click(object sender, EventArgs e)
{
numArray[count] = convert.ToDouble(textBox1.Text);
count++;
displayNum.Visible = true;
displayNum.Text = count.ToString();
;
}