[英]C# console application: Main method return value VS Application.ExitCode
[英]Changing a source file to compile Main() method in a project, in VS c# console application
我有一個示例c#console項目,其中有2個程序文件:
在Program.cs中,我有通常的main方法,它是項目的入口點:
public static void main(string[] args)
{
Console.WriteLine("hello world from Program.cs");
}
但是我想從Program02.cs文件中執行程序,所以我在文件中添加了方法。
public static void main(string[] args)
{
Console.WriteLine("hello world from Program02.cs");
}
顯然它不起作用,項目的入口點/執行從Program.cs開始,如何將主執行方法切換到Program02.cs文件?
在解決方案資源管理器中右鍵單擊該項目,然后找到:
Main()
方法的首選類 ! 你聲明你的Main()
方法是這樣的: main()
,這是不正確的。 它必須是Main()
。 C#是一種區分大小寫的語言。
檢查一下:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.