C#入口点函数 [英] C# entry point function
本文介绍了C#入口点函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
时staic无效的主要()是在C#中必要的入口点函数,或者我们可以使用一些其他的功能呢?
为什么main()的是静态的?
Is staic void main() is necessary for entry point function in C# or we can use some other functions? Why main() is static?
推荐答案
是的,它必须是主
。这是静态的,因为否则CLR将需要担心创建类型的实例 - 这意味着你大概得有一个参数的构造函数,即使你没有的希望的类型的实例等你为什么会希望的强制它是一个实例方法?
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?
这篇关于C#入口点函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文