Add Console.Out to TextWriterTraceListener : Debug : Development C# Examples


C# Examples » Development » Debug »

 

Add Console.Out to TextWriterTraceListener









    
#define  DEBUG

using  System;
using  System.Globalization;
using  System.Diagnostics;

class  MainClass
{
    public  static  void  Main()  
    {
        TextWriterTraceListener  tl  =  new  TextWriterTraceListener(Console.Out);
        Debug.Listeners.Add(tl);

        Debug.WriteLine("Starting  Main()");

        Debug.Assert(1  ==  2,  "1==2");

        Debug.WriteLine("Exiting  Main()");
    }
}
    
   
  
   



Output

Starting Main()
Fail: 1==2
Exiting Main()


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Debug