Yes I ran into this problem too, my first 2 days with VS2012. Where is my console output? it flashes and disappears. Mystified by usefull examples like
https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b
Ok, indeed @martynaspikunas .. trick you can replace Console.WriteLine() by Debug.WriteLine() to see it in the IDE. It will stay there, nice.
But sometimes you have to change a lot of places in existing code to do that.
I did find a few alternatives.. How about a single
Console.ReadKey();
in Program.cs ? The console will wait for you, it can scroll..
I also like to use the Console output in my Winforms contexts:
class MyLogger : System.IO.TextWriter
{
private RichTextBox rtb;
public MyLogger(RichTextBox rtb) { this.rtb = rtb; }
public override Encoding Encoding { get { return null; } }
public override void Write(char value)
{
if (value != '\r') rtb.AppendText(new string(value, 1));
}
}
Add this class after your main form class. Then plug it in, using the following redirect statement in the constructor, after InitializeComponent() is called:
Console.SetOut(new MyLogger(richTextBox1));
As a result of this, all your Console.WriteLine() will appear in the richTextBox.
Sometimes I use it to redirect to a List to report Console later, or dump it to a textfile.
Note: the MyLogger code snippet was put here by Hans Passant in 2010,
Bind Console Output to RichEdit