c# : console application - static methods

前端 未结 5 715
[愿得一人]
[愿得一人] 2020-12-24 01:26

why in C#, console application, in \"program\" class , which is default, all methods have to be static along with

static void Main(string[] args)

5条回答
  •  清酒与你
    2020-12-24 01:50

    Not all methods have to be static, you can add instance methods and also create an instance of your Program class.
    But for Main it has to be static beacause it's the entry point of your application and nobody is going to create an instance and call it.

提交回复
热议问题