[c#] Why doesn't Console.Writeline, Console.Write work in Visual Studio Express?

I just open a console application and I type

Console.WriteLine("Test");

But the output window doesn't show this. I go to the output window with Ctrl+W,O

But nothing shows up when I run my program, am I nuts or is this not supported in the visual studio 2010 express?

This question is related to c# visual-studio-2010

The answer is


It's more than likely because you've used Console in the namespace. For example like this:

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

Try removing it from the namespace or use the full namespace instead i.e.

   System.Console.Writeline("abc");

Console.Writeline() shows up in the debug output (Debug => Windows => Output).


There are 2 possible problems are:

  • Firstly, you have not used the using System which should be before writing code that uses "System class", as Console.WriteLine()
  • Secondly, you have not coded what happens after the Console displays "Test"

The possible solution will be:

using System;

namespace Test
{
    public static Main()
    {
        //Print to the console
        Console.WriteLine("Test");

        //Allow user to read output
        Console.ReadKey();
    }
}

It is also strategic to code Console.Write("Press any key to exit..."); on the line that precedes the Console.ReadKey(); to make the user aware that the program is ending, he/she must press any key to exit.


using System.Diagnostics;


Trace.WriteLine("This line will show on Output window"); 
Trace.Flush();

This works on Microsoft Team Explorer for Visual Studio 2013

Refer to microsoft.com


Workaround I found:

Press Ctrl + Alt + I or navigate to "Debug Tab" ---> "Windows" ---> "Immediate".

In your code write:

Trace.WriteLine("This is one of the workaround");

Go to the Debug menu and select Options and uncheck "Redirect all Output Window text to Immediate Window"


If you use Ctrl-F5 (start without debugging) it will leave the console window open with a message "Press any key to continue". That's the easiest way to keep the console window from closing so you can see the console output.


Or you can debug by CTRL+F5 this will open ConsoleWindow waits after last line executed untill you press key.


Try ctrl+F5, it will hold your Screen until you press any key. Regards


Go to properties in you own project in Solution Explorer window and choose application type and look for Output Type and change it's value to Console Application . This will make console screen besides your form. If you close console screen, your form will be closed too.

Good luck.


I run into a similar problem while running a Unit Test. Console.WriteLine() did not write anything into the VS Output Window.

Using System.Diagnostics.Debug.WriteLine() solved the problem.


Right click on the project in solution-explorer and click "clean".

Now run F5

Make sure the code is as below:

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

In Winforms app, both methods:

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

and

System.Console.WriteLine("my string")

write to the output window.

In AspNetCore app, only System.Diagnostics.Debug.WriteLine("my string") writes to the output window.


Perhaps the console is clearing. Try:

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

And it will hopefully stay there until you press enter.


If you are developing a command line application, you can also use Console.ReadLine() at the end of your code to wait for the 'Enter' keypress before closing the console window so that you can read your output.


The output window isn't the console. Try the methods in System.Diagnostics.Debug


The Output window of Visual Studio 2017 have a menu called Show output from, in my case ASP.NET Core Web Server was the option to select in order to see the printed out, I came across this issue since I had it set to Build so I wasn't seeing the printed out lines at runtime.


No satisfactory answers provided.

System.Diagnostics.Debug.WriteLine() will write messages to the Output:debug window, but so much crap is constantly dumped into that window by every process under the sun, it is like finding a needle in a haystack to find YOUR messages.

Console.WriteLine() does not write to any window in Visual Studio. I guess it will only write to the application console if your application creates a console in the first place, i.e. if it is a Console application.

Why is the tooling making the simple task of having your web application server side code .cs code write some debug messages into a window which is swamped with crap making it almost impossible to find your information?