나는 C#에서 programm를 만들었습니다. 코드에서 내가했습니다 int
전화 : Paying
을하지만 그것을 가치를 부여 할 때, 그것은 다음과 같은 오류 말한다 : 나는 무엇을해야하는지에int에 값을 제공하는 중 오류가 발생했습니다.
An object reference is required for the non-static field, method or property 'Mc_Donalds.Program.Paying'
어떤 제안이?
public int Paying;
// Select what meal you want
Console.WriteLine("To order please type the number infront of the item.");
int Keuze = Convert.ToInt32(Console.ReadLine());
if (Keuze == 1)
{
Paying = 5;
}
else if (Keuze == 2)
{
Paying = 3.50;
}
else if (Keuze == 3)
{
Paying = 1;
}
else if (Keuze == 4)
{
Paying = 6;
}
Program
에서 클래스 이름을 가정으로 사용하려고합니다. –도움이 필요하면 코드를보아야합니다. – Rex
일반적으로 이러한 오류는 인스턴스 메서드를 호출하려고하지만 인스턴스를 지정하지 않고 오류를 발생시키는 것을 의미합니다. – kevchadders