Demonstrates debug output : Trace Listener : Development C# Examples


C# Examples » Development » Trace Listener »

 

Demonstrates debug output









    
#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
» Trace Listener