Where can I read the Console output in Visual Studio 2015
C#Visual StudioConsoleVisual Studio-2015C# Problem Overview
I am new to C# and downloaded the free version of Microsoft Visual Studio 2015. To write a first program, I created a Windows Forms Application. Now I use Console.Out.WriteLine()
to print some test data. But where can I read the console?
C# Solutions
Solution 1 - C#
The simple way is using System.Diagnostics.Debug.WriteLine()
Your can then read what you're writing to the output by clicking the menu "DEBUG" -> "Windows" -> "Output".
Solution 2 - C#
in the "Ouput Window". you can usually do CTRL-ALT-O to make it visible. Or through menus using View->Output.
Solution 3 - C#
You can run your program by: Debug -> Start Without Debugging
. It will keep a console opened after the program will be finished.
Solution 4 - C#
What may be happening is that your console is closing before you get a chance to see the output. I would add Console.ReadLine();
after your Console.WriteLine("Hello World");
so your code would look something like this:
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadLine();
}
This way, the console will display "Hello World" and a blinking cursor underneath. The Console.ReadLine();
is the key here, the program waits for the users input before closing the console window.
Solution 5 - C#
Solution 6 - C#
Solution 7 - C#
You should use Console.ReadLine() if you want to read some input from the console.
To see your code running in Console:
In Solution Explorer (View - Solution Explorer from the menu), right click on your project, select Open Folder in File Explorer, to find where your project path is.
Supposedly the path is C:\code\myProj .
Open the Command Prompt app in Windows.
Change to your folder path. cd C:\code\myProj
Change to the debug folder, where you should find your program executable. cd bin\debug
Run your program executable, it should end in .exe extension.
Example:
myproj.exe
You should see what you output in Console.Out.WriteLine() .