我正在尝试制作一个程序来查找动态双打数的平均值,但我需要参考其他方法中的项目。
public int count = 0;
public double[] nums = new double[1000];
public Form1()
{
InitializeComponent();
label3.Text = "";
}
public void button1_Click(object sender, EventArgs e)
{
count++;
string mucho = textBox1.Text;
nums[count] = Double.Parse(mucho);
string countstr = Convert.ToString(count);
label3.Text = countstr;
}
public void button2_Click(object sender, EventArgs e)
{
double average = 0;
int count2 = 0;
string countstr2 = label3.Text;
int value = Convert.ToInt32(countstr2);
while (count2 <= value)
{
count2++;
average = +nums[count2];
}
double average2;
average2 = average / count2;
string ans = Convert.ToString(average2);
label2.Text = ans;
}