November 2001
Beginner to intermediate
816 pages
16h 3m
English
A program's capability to turn debugging on and off as needed is called conditional debugging. During development, output from debugging can clutter up normal output or force paths of execution that isn't necessary on every run. The System.Diagnostics namespace has both attributes and switches to turn debugging on and off as necessary. Listing 31.3 shows how to use attributes to control conditional debugging.
#define DEBUG using System; using System.Diagnostics; /// <summary> /// Conditional Debug Demo. /// </summary> class ConditionalDebugDemo { static bool Debugging = true; [Conditional("DEBUG")] static void SetupDebugListener() { TextWriterTraceListener ... |
Read now
Unlock full access