I am new to C#, sorry if this is duplicate. I am simply trying to add two variables together but I get the error from the title
An object reference is required for the non-static field, method, or property 'Program.x'
Here is code
using System;
namespace HelloWorld
{
class Program
{
int x = 3;
int y = 10;
static void Main(string[] args)
{
int mathResults = x + y;
string results = mathResults.ToString();
Console.WriteLine("Hello World!");
}
}
}
Could someone please explain WHY I am getting this error? Thank you!