How to set startup object in console application in C#?

妖精的绣舞 提交于 2020-01-24 07:59:08

问题


I know this is not tough but still I am facing a problem, I have created one console application Named Console Application, Under this application, there are two class one is Program.cs, Delegate.cs. When I am trying to run Delegate.cs but always running Program.cs. Even I tried to set the startup object from properties But there Delegate.cs is not appearing in Drop Down List. A code is here---

class program
{
   public static  void Main()
   {
    Console.WriteLine("I am from program.cs");
   }

}

class Delegate
{
   public static  void Main()
   {
    Console.WriteLine("I am from Delegate.cs");
   }
}

I am using Visual Studio 2015.


回答1:


Maybe you need to:

  1. Compile first (Ctrl+Shift+B)

  2. Use another word instead of Delegate

  3. Try giving your method an args parameter Main(string[] args)

It works for me:



来源:https://stackoverflow.com/questions/49585823/how-to-set-startup-object-in-console-application-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!