Windows窗体应用程序控制台输出
我有一个可以从UI和Windows窗体应用程序控制台输出,windows,visual-studio,Windows,Visual Studio,我有一个可以从UI和cmd运行的应用程序。当它从控制台运行时,我需要打印一些东西作为输出。下面是Main()方法: [STAThread] static void Main() { string[] args = Environment.GetCommandLineArgs(); foreach (var arg in args) { if (arg == "-T") {
cmd
运行的应用程序。当它从控制台运行时,我需要打印一些东西作为输出。下面是Main()
方法:
[STAThread]
static void Main()
{
string[] args = Environment.GetCommandLineArgs();
foreach (var arg in args)
{
if (arg == "-T")
{
Console.WriteLine("Example!!!"); //Nothing happens
return;
}
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
在这种情况下如何打印输出?到底发生了什么?控制台窗口是否在闪烁后消失,而不是显示输出??不,它没有消失。我已经使用
cmd
窗口中的app.exe-T
运行了我的应用程序。代码似乎没有问题,请添加代码以从输入流中读取行。它只是在行控制台上停止。ReadLine您能在此处更新代码吗?