C# entry point function

前端 未结 6 631
闹比i
闹比i 2020-11-29 12:55

Is staic void main() is necessary for entry point function in C# or we can use some other functions? Why main() is static?

6条回答
  •  情歌与酒
    2020-11-29 13:47

    Yes, it has to be Main. It's static because otherwise the CLR would need to worry about creating an instance of the type - which means you'd presumably have to have a parameterless constructor, even if you didn't want an instance of the type, etc. Why would you want to force it to be an instance method?

提交回复
热议问题