为了用一个简单的例子来解释这个问题,让我们说:
我有一个取两个数字平均值的方法:
private double TakeAverage(double n1,double n2)
{
average = (number1 + number2) / 2.0000;
return average;
}
我称之为:
textBox3.Text = (TakeAverage(number1, number2)).ToString();
Q1:
如何使此函数能够运行而无需多次调用它,例如:
TakeAverage(number1, number2, number3, number4, number5) // as wanted number of times...
Q2:如何使这个函数通过它所接受的值的数量来改变返回值?
例如
Substring(1) //if it takes just one value, it returns all the chars after first char but
Substring(1,2)//if it takes two values, it returns 2 characters after first char