1

I've been doing some beginner-level C# lately and I love the new Visual Studio and all, but is it possible to make my program output (when using Console, for example) appear on the little text area where errors are reported rather than a separate command line interface? In Eclipse and NetBeans, this is possible with Java.

I'm not particularly a fan of the CLI appearing every time I want to test a new line. I wonder if there is an option to have the output appear on the bottom of the same window like in NetBeans.

3 Answers 3

2

This is rather a workaround, as I'm unaware of of a setting in visual studio to achieve this, but you could replace (or write a method which does both) Console.WriteLine with Debug.WriteLine.

Sign up to request clarification or add additional context in comments.

1 Comment

You can also use Trace.WriteLine if you want to see these messages when application is running in non-debug mode.
1

No, writing a console program will always allocate a new window when using Visual Studio. However, you can display messages in the output window, take a look at Debug.WriteLine.

If I have a lot of messages to output, I will usually write a small utility method.

using System; using System.Diagnostics; class Program { static void Main() { WriteLine("Hello"); WriteLine("The number is {0}", 42); } static void WriteLine(string format, params object[] args) { string message = String.Format(format, args); Console.WriteLine(message); Debug.WriteLine(message); } } 

2 Comments

Hm, not quite as convenient as I'd hoped. But as long as it works, I guess. Thanks for your answer! +1
I agree, it is quite inconvenient, but I think I can guess why they wouldn't allow you to do that. It wouldn't be able to capture any input (as the output window is read only) and what would happen if you called Console.SetCursorPosition(0, 0)? I'd hate to think about that one.
0

This has been answered pretty well in another StackOverflow question. Here's the link to it: redirect-console-to-visual-studio-debug-output-window-in-app-config

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.