Taylor
Taylor

Reputation: 143

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.

Upvotes: 8

Views: 12990

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65682

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

Upvotes: 8

Related Questions