新手请教一个简单的调用问题
private double[] arr(double[] c)
{
double q = 1,w = 1,y = 1,r = 1;
c = new double[4]{q,w,y,r};
c[0] = q * 2;
c[1] = w * 3;
c[2] = y * 4;
c[3] = r * 5;
return c;
}
private void button1_Click(object sender, EventArgs e)
{
double q1 = 1, w1 = 2, y1 = 3, r1 = 4;
double[] b ={ q1, w1, y1, r1 };
arr(b);
this.label3.Text = b[3].ToString();
}
b[3]的结果是4而不是20,请问哪里错了?
------解决方案---------------------_-#,还真没见过你这种写法
你这里
double q = 1,w = 1,y = 1,r = 1;
c = new double[4]{q,w,y,r};
给它重新赋值了,它怎么可能得20
这样
private double[] arr(double[] c)
{
c[0] *= 2;
c[1] *= 3;
c[2] *= 4;
c[3] *= 5;
return c;
}