我只是打开一个控制台应用程序,然后输入
Console.WriteLine("Test");
但是输出窗口没有显示这一点。我用Ctrl + W, O切换到输出窗口。
但是当我运行程序时什么都没有显示。是我疯了还是这在Visual Studio 2010 Express中不支持?
我只是打开一个控制台应用程序,然后输入
Console.WriteLine("Test");
但是输出窗口没有显示这一点。我用Ctrl + W, O切换到输出窗口。
但是当我运行程序时什么都没有显示。是我疯了还是这在Visual Studio 2010 Express中不支持?
当前回答
我找到了一个变通办法:
按Ctrl + Alt + I或导航到调试选项卡→Windows→立即。
在你的代码中写:
Trace.WriteLine("This is one of the workarounds");
其他回答
如果你使用Ctrl-F5(启动不调试),它将留下控制台窗口打开的消息“按任意键继续”。这是防止控制台窗口关闭的最简单方法,这样您就可以看到控制台输出。
这里没有一个答案对我有用!!这里的大多数人都被困在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.
在Windows窗体应用程序中,
System.Diagnostics.Debug.WriteLine("my string")
and
System.Console.WriteLine("my string")
写入输出窗口。
在ASP中。NET核心应用,只有System.Diagnostics.Debug。WriteLine("my string")写到输出窗口。
也许控制台正在清理。试一试:
Console.WriteLine("Test");
Console.ReadLine();
在你按回车键之前,它会一直在那里。
有两个可能的问题:
首先,在编写使用“System类”的代码之前,你没有使用过using System,比如Console.WriteLine() 其次,您还没有编写控制台显示“Test”后发生的事情。
可能的解决方案是:
using System;
namespace Test
{
public static Main()
{
//Print to the console
Console.WriteLine("Test");
//Allow user to read output
Console.ReadKey();
}
}
编写控制台代码也是有战略意义的。写(“按任意键退出…”);在Console.ReadKey()之前的行;为了让用户意识到程序正在结束,他/她必须按任意键退出。