어떻게이 오류를 해결할 수 있습니까?"메소드에 과부하가 없습니다." '0 인수가 필요합니다. "
"메서드 'output'에 대한 오버로드가 0 개의 인수를 필요로합니다."
오류는 "fresh.output();"의 맨 아래에 있습니다.
내가 뭘 잘못하고 있는지 모르겠다. 누군가 코드를 수정하기 위해 무엇을해야하는지 말해 줄 수 있습니까? 방법 "출력"인수를 필요로 함을 말하고
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication_program
{
public class Numbers
{
public double one, two, three, four;
public virtual void output(double o, double tw, double th, double f)
{
one = o;
two = tw;
three = th;
four = f;
}
}
public class IntegerOne : Numbers
{
public override void output(double o, double tw, double th, double f)
{
Console.WriteLine("First number is {0}, second number is {1}, and third number is {2}", one, two, three);
}
}
public class IntegerTwo : Numbers
{
public override void output(double o, double tw, double th, double f)
{
Console.WriteLine("Fourth number is {0}", four);
}
}
class program
{
static void Main(string[] args)
{
Numbers[] chosen = new Numbers[2];
chosen[0] = new IntegerOne();
chosen[1] = new IntegerTwo();
foreach (Numbers fresh in chosen)
{
fresh.output();
}
Console.ReadLine();
}
}
}
나는 당신이 이해하지 못하는 무엇인지 ... 좀 더 포괄적 인 오류 메시지에 대해 생각하지 수 ? –
fresh.output(); 여기서 매개 변수를 전달하면 출력과 같아야합니다 (double o, double tw, double th, double f). – Anand
오류 메시지가 분명하지 않습니까? –