如何在 C# 中的控制台应用程序中设置启动对象? [英] How to set startup object in console application in C#?
问题描述
我知道这并不难,但我仍然面临一个问题,我创建了一个名为 Console Application 的控制台应用程序,在这个应用程序下,有两个类,一个是 Program.cs,Delegate.cs.当我尝试运行 Delegate.cs 但始终运行 Program.cs 时.甚至我试图从属性设置启动对象但是 Delegate.cs 没有出现在下拉列表中.代码在这里---
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");
}
}
我使用的是 Visual Studio 2015.
I am using Visual Studio 2015.
推荐答案
也许你需要:
先编译(Ctrl+Shift+B)
用另一个词代替Delegate
尝试给你的方法一个 args 参数 Main(string[] args)
Try giving your method an args parameter Main(string[] args)
它对我有用:
这篇关于如何在 C# 中的控制台应用程序中设置启动对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!