Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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");
   }
}

enter image description here

I am using Visual Studio 2015.

like image 707
Taylor Avatar asked Mar 31 '18 08:03

Taylor


1 Answers

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: enter image description here

like image 122
Jeremy Thompson Avatar answered Oct 10 '22 04:10

Jeremy Thompson