Using the Debug and Trace Classes

for RuBoard

The useful methods and properties are static. The overloaded WriteLine and Write are used to write debug or trace output. The overloaded WriteLineIf and WriteIf write output if the condition in their first argument is true.

 Debug.WriteLine("This was compiled with a DEBUG                                               directive!");  Trace.WriteLine("This was compiled with a TRACE                                               directive!");  ...  Debug.WriteLineIf(DebugBooleanSwitch.Enabled, "Debug                       Boolean Switch enabled at startup.");  Debug.WriteLineIf(!DebugBooleanSwitch.Enabled,               "Debug Boolean Switch disabled at startup."); 

Output is indented with the Indent and Unindent methods . The indentation size is controlled with the IndentSize property.

 Trace.Indent();  ...  Trace.IndentSize = 10; 

You can also set the indentation size in the application configuration file.

 <?xml version="1.0"?>  <configuration>      <system.diagnostics>         <trace indentsize="15" />      </system.diagnostics>  </configuration> 

The Assert method can check an assertion. The AutoFlush property and the Flush method control the flushing of the output buffer.

for RuBoard


Application Development Using C# and .NET
Application Development Using C# and .NET
ISBN: 013093383X
EAN: 2147483647
Year: 2001
Pages: 158

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net