Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write to the Visual Studio Output window 1

Status
Not open for further replies.

d00ape

Programmer
Apr 2, 2003
171
SE
How do I write to the Visual Studio Output window? Can I read user input from there like I can in Eclipse?
 
As far as I am aware you cannot get user input from it but you can write to it with:

Console.Write("My Message" + myVar);

Age is a consequence of experience
 
How do I write to the Visual Studio Output window?

Like this

Code:
System.Diagnostics.Debug.WriteLine("Message"); 
// OR
System.Diagnostics.Trace.WriteLine("Message");

Use Trace if you want to do this in a release build, debug if you only want to do it while debugging.

Can I read user input from there like I can in Eclipse?
No.


What you are probably after is a Console application. But this writes to a console window which is a totally different thing to the output window.

To create a console project go to File->New->Project...->C# Projects->Console Application.

You will get a class in this project with a main function. In this function you can use Console.ReadLine(myString) and Console.WriteLine().

TIP: To stop the console window closing before you have had a chance to read your output place a Console.ReadLine() at the end of your app.
 
litton1

It depends upon what type of application you are developing. If you develop a windows appliation then System.Console.Write does write to the Output window. If you are developing a console application then it doesn't. I've not tried for any other type of project.

System.Diagnostics.Trace.Write writes to the output window for all types of project, so I in my humble opinion it is the preferred solution, but not the only one.

Given that d00ape wants input as well as output, it definatly sounds like a console application is the way to go.
 
I see, thank you for the explanation.

Age is a consequence of experience
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top