c#中main函数的含义是什么 [英] what is mean by main function in c#
本文介绍了c#中main函数的含义是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我们知道所有c#程序都以一个功能开始
Hello,
As we know that all c# program start with a Fuction
class program
{
public Static void Main()
{
{
//
}
}
然后需要什么公共静态void Main()
是程序可运行没有这个功能,如果是,那么为什么
then what is the need of public Static void Main()
is program is runnable without this function if yes then why
推荐答案
所有程序都需要从某处开始:static
主要方法是所有开始的地方 - 它必须是在程序开始时可以访问的某个地方 - 所以它不能是类构造函数(因为没有什么可以构造第一个类的第一个实例)所以它必须是一个静态
方法。它被称为Main,因此链接器等等都知道要查找的内容!
如果它不被称为Main,则需要一个名称某种形式 - 所以.NET框架的设计者选择了一个名字并坚持下去。它可以追溯到C天,它被称为主。
All programs need to start somewhere: thestatic
Main method is the place that it all begins - it has to be somewhere that is accessible at the start of the program - so it can''t be a class constructor (because there is nothing to construct the first instance of the first class) so it has to be astatic
method. It is called Main simply so that the linker and so forth all know exactly what to look for!
If it wasn''t called Main, it would need a name of some kind - so the designers of teh .NET framework picked a name and stuck with it. It harks back to "C" days, where it was called "main" instead.
Main()和其他方法(C#vs Java) [ ^ ]
您需要一个程序的入口点,以便运行时知道从哪里开始执行它。
请同时参考这个问题及所有解决方案:为什么main()函数在c#中应该是静态的? [ ^ ]。
问候,
- Manfred
You need an entry point for a program so the runtime knows where to start executing it.
Please also refer to this question and all the solution: Why main() function should be static in c#?[^].
Regards,
— Manfred
这篇关于c#中main函数的含义是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文