Add the Console as a TraceListener (to have Trace messages treated as Console output)


/ Published in: C#
Save to your folder(s)

This is particularly useful for unit testing, but you could do it anywhere in your code.


Copy this code and paste it in your HTML
  1. //Use TestInitialize to run code before running each test
  2. [TestInitialize()]
  3. public void MyTestInitialize()
  4. {
  5. Trace.Listeners.Add(new ConsoleTraceListener());
  6. }
  7.  
  8. // Implementation
  9. Trace.WriteLine("Tracing my program execution");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.