我只是打开一个控制台应用程序,然后输入

Console.WriteLine("Test");

但是输出窗口没有显示这一点。我用Ctrl + W, O切换到输出窗口。

但是当我运行程序时什么都没有显示。是我疯了还是这在Visual Studio 2010 Express中不支持?


当前回答

这里没有一个答案对我有用!!这里的大多数人都被困在Windows桌面应用程序控制台。如果你是一个使用ASP的web开发人员。NET在Visual Studio中看不到任何控制台或调试文本,下面是如何修复这个问题:

Paste the following two tests into your code so it runs both lines. These are tests for the output window: System.Console.WriteLine($"hello console!"); System.Diagnostics.Debug.WriteLine($"hello debugger!"); In Visual Studio choose VIEW > OUTPUT. You will see the results above in this output window after changing two settings below. When NOT DEBUGGING, in the OUTPUT window at the top under "Show Output From" choose: "YourProjectName - ASP.NET CORE Web Server". Run your code. You should see the "Console" text above. When DEBUGGING, in the OUTPUT window at the top under "Show Output From" choose: "Debugger". Run your code in debug mode. You should see the "Debug" text above.

其他回答

控制台。WriteLine将输出写入应用程序打开的控制台窗口(想象一下当您打开命令提示符时出现的带有白色文本的黑色窗口)。试试System.Diagnostics.Debug.WriteLine吧。

在Windows窗体应用程序中,

System.Diagnostics.Debug.WriteLine("my string")

and

System.Console.WriteLine("my string")

写入输出窗口。

在ASP中。NET核心应用,只有System.Diagnostics.Debug。WriteLine("my string")写到输出窗口。

这里没有一个答案对我有用!!这里的大多数人都被困在Windows桌面应用程序控制台。如果你是一个使用ASP的web开发人员。NET在Visual Studio中看不到任何控制台或调试文本,下面是如何修复这个问题:

Paste the following two tests into your code so it runs both lines. These are tests for the output window: System.Console.WriteLine($"hello console!"); System.Diagnostics.Debug.WriteLine($"hello debugger!"); In Visual Studio choose VIEW > OUTPUT. You will see the results above in this output window after changing two settings below. When NOT DEBUGGING, in the OUTPUT window at the top under "Show Output From" choose: "YourProjectName - ASP.NET CORE Web Server". Run your code. You should see the "Console" text above. When DEBUGGING, in the OUTPUT window at the top under "Show Output From" choose: "Debugger". Run your code in debug mode. You should see the "Debug" text above.

也许控制台正在清理。试一试:

Console.WriteLine("Test");
Console.ReadLine();

在你按回车键之前,它会一直在那里。

没有提供令人满意的答复。

System.Diagnostics.Debug.WriteLine()将向Output:debug窗口写入消息,但如此多的垃圾被太阳下的每个进程不断地倾倒到该窗口中,这就像大海捞针一样。

Console.WriteLine()不会写入Visual Studio中的任何窗口。我猜只有当你的应用程序首先创建了一个控制台,也就是说,如果它是一个控制台应用程序,它才会写入应用程序控制台。