函数带参数返回值的问题,还没搞明白是什么概念,那位详细给解释下函数带参数返回值问题,有能力的来,说的好的,奖励10个Q币!5袋肥料!如果你要其他的也可以商量!例如:
class Program//函数的参数
{
static double bigger(double.x,double,y)
{
if(x>=y)
{
Console.WriteLine(x);
}
else
Console.WriteLine(y);
return bigger;//到底返回啥东西给bigger啊、
}
class Program//函数的参数
{
static double bigger(double.x,double,y)
{
if(x>=y)
{
Console.WriteLine(x);
}
else
Console.WriteLine(y);
return bigger;//到底返回啥东西给bigger啊、
}
static double bigger(double.x,double,y)
{
return x>y?x:y;
}这样写就可以了。
static double bigger(double.x,double,y)
{
Console.WriteLine(x>y?x:y);
return x>y?x:y;
}
这样可以带着输出。
static double bigger(double.x,double,y)
{
double bigger_one = 0;
if(x>=y) bigger_one = x;
else bigger_one = y;
return bigger_one;
}
不需要以身相许了。
你为什么要将bigger转化为委托类型double呢?如果一定要用 if 的话,可以这样写:
class Program //函数的参数
{
static double bigger(double x, double y)
{
if (x >= y)
{
Console.WriteLine(x);
return x;
}
Console.WriteLine(y);
return y;
}
{
//这里是形参
static double bigger(double x,double y)
{
double bigger_one = 0;
if(x>=y) bigger_one = x;
else bigger_one = y;
return bigger_one;
}
}
class Test
{
static void Main(string[] args){
//这里是实参 实际你要传入的值,形参那儿只是声明你将要传入值的类型
double result=Program.bigger(1.0,3.0);
}
}