不能根据返回值来重载方法是什么意思
他的意思是否重载的返回类型要求是一致的?
但是我试了一下不同的返回类型,是可以的
using System;
using System.Collections.Generic;
using System.Text;
namespace homework4_1
{
class Program
{
double num;
public void MyMethod(int a,int b)
{
num=Math.Pow(a, b);
Console.WriteLine(num);
}
public int MyMethod(int a, int b,int c)
{
return a * b*c;
}
static void Main(string[] args)
{
Program test = new Program();
test.MyMethod(3,2);
int num = test.MyMethod(2, 2, 2);
Console.WriteLine(num);
}
}
}