0
static methods
Why methods that called from the Main have to be static methods?
2 odpowiedzi
0
Well, because the Main method is static too:( .And you can call only static methods from static method. And Main must be static as entry point of program
Tu avoid it, you have to create another class, and in Main method create its object.This way
namespace ConsoleApplication6
{
class MyClass
{
public void Hello() { Console.WriteLine("Hello"); }
}
class Program
{
static void Main(string[] args)
{
MyClass A = new MyClass();
A.Hello();
}
}
}
0
Thank you