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

Console.WriteLine("Test");

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

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


当前回答

这很可能是因为您在名称空间中使用了Console。比如这样:

namespace XYZApplication.Console
{
    class Program
    {
        static void Main(string[] args)
       {
            //Some code;             
       }
    }
}

尝试从命名空间中删除它或使用完整的命名空间。

   System.Console.Writeline("abc");

这是一个问题这是一个问题是因为您可能有另一个冲突的名称空间。例子:

using System;
using AnotherNamespaceThatContainsAConsoleClass;

其他回答

这里没有一个答案对我有用!!这里的大多数人都被困在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.

尝试按Ctrl + F5。它将保持你的屏幕,直到你按下任何键。

输出窗口不是控制台。尝试System.Diagnostics.Debug中的方法

我在运行单元测试时遇到了类似的问题。Console.WriteLine()没有向Visual Studio输出窗口写入任何内容。

使用System.Diagnostics.Debug.WriteLine()解决了这个问题。

如果你使用Ctrl-F5(启动不调试),它将留下控制台窗口打开的消息“按任意键继续”。这是防止控制台窗口关闭的最简单方法,这样您就可以看到控制台输出。