问题
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:
Compile first (Ctrl+Shift+B)
Use another word instead of Delegate
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