当我使用main();它显示错误 [英] when I use main(); it shows error
本文介绍了当我使用main();它显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我解决上述问题
推荐答案
你没有使用main();在Windows中 - 它由系统自动为您调用。
对于控制台应用程序,您只需要声明它:
You don't "use main();" in Windows - it is called automatically for you by the system.
For a console app you just need to declare it:
namespace MyNamespace
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.ReadLine();
}
}
}
对于winforms应用程序,它是为您创建的:
For a winforms app it is created for you:
namespace MyNamespace
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
你不应该明确地调用main
,因为它是入口点 [ ^ ](即操作系统,调用main
启动您的应用程序应用程序执行)。
You shouldn't explicitly callmain
, since it is the entry point[^] of your application (that is the operative system, callsmain
to start your application execution).
这篇关于当我使用main();它显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文