mscorlib(4.0.0.0) API with additions
System.Diagnostics.Debug Class Reference

Provides a set of methods and properties that help debug your code. More...

Static Public Member Functions

static void Flush ()
 Flushes the output buffer and causes buffered data to write to the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void Close ()
 Flushes the output buffer and then calls the Close method on each of the P:System.Diagnostics.Debug.Listeners. More...
 
static void Assert (bool condition)
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
static void Assert (bool condition, string message)
 Checks for a condition; if the condition is false, outputs a specified message and displays a message box that shows the call stack. More...
 
static void Assert (bool condition, string message, string detailMessage)
 Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the call stack. More...
 
static void Assert (bool condition, string message, string detailMessageFormat, params object[] args)
 Checks for a condition; if the condition is false, outputs two messages (simple and formatted) and displays a message box that shows the call stack. More...
 
static void Fail (string message)
 Emits the specified error message. More...
 
static void Fail (string message, string detailMessage)
 Emits an error message and a detailed error message. More...
 
static void Print (string message)
 Writes a message followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void Print (string format, params object[] args)
 Writes a formatted string followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void Write (string message)
 Writes a message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void Write (object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void Write (string message, string category)
 Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void Write (object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void WriteLine (string message)
 Writes a message followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void WriteLine (object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void WriteLine (string message, string category)
 Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void WriteLine (object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void WriteLine (string format, params object[] args)
 Writes a formatted message followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection. More...
 
static void WriteIf (bool condition, string message)
 Writes a message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void WriteIf (bool condition, object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void WriteIf (bool condition, string message, string category)
 Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void WriteIf (bool condition, object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, string message)
 Writes a message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, string message, string category)
 Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true. More...
 
static void Indent ()
 Increases the current P:System.Diagnostics.Debug.IndentLevel by one. More...
 
static void Unindent ()
 Decreases the current P:System.Diagnostics.Debug.IndentLevel by one. More...
 

Properties

static TraceListenerCollection Listeners [get]
 Gets the collection of listeners that is monitoring the debug output. More...
 
static bool AutoFlush [get, set]
 Gets or sets a value indicating whether M:System.Diagnostics.Debug.Flush should be called on the P:System.Diagnostics.Debug.Listeners after every write. More...
 
static int IndentLevel [get, set]
 Gets or sets the indent level. More...
 
static int IndentSize [get, set]
 Gets or sets the number of spaces in an indent. More...
 

Detailed Description

Provides a set of methods and properties that help debug your code.

Definition at line 8 of file Debug.cs.

Member Function Documentation

◆ Assert() [1/4]

static void System.Diagnostics.Debug.Assert ( bool  condition)
static

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.

Definition at line 86 of file Debug.cs.

◆ Assert() [2/4]

static void System.Diagnostics.Debug.Assert ( bool  condition,
string  message 
)
static

Checks for a condition; if the condition is false, outputs a specified message and displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the specified message is not sent and the message box is not displayed.
messageThe message to send to the P:System.Diagnostics.Trace.Listeners collection.

Definition at line 96 of file Debug.cs.

◆ Assert() [3/4]

static void System.Diagnostics.Debug.Assert ( bool  condition,
string  message,
string  detailMessage 
)
static

Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the specified messages are not sent and the message box is not displayed.
messageThe message to send to the P:System.Diagnostics.Trace.Listeners collection.
detailMessageThe detailed message to send to the P:System.Diagnostics.Trace.Listeners collection.

Definition at line 107 of file Debug.cs.

◆ Assert() [4/4]

static void System.Diagnostics.Debug.Assert ( bool  condition,
string  message,
string  detailMessageFormat,
params object []  args 
)
static

Checks for a condition; if the condition is false, outputs two messages (simple and formatted) and displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the specified messages are not sent and the message box is not displayed.
messageThe message to send to the P:System.Diagnostics.Trace.Listeners collection.
detailMessageFormatThe composite format string (see Remarks) to send to the P:System.Diagnostics.Trace.Listeners collection. This message contains text intermixed with zero or more format items, which correspond to objects in the args array.
argsAn object array that contains zero or more objects to format.

Definition at line 119 of file Debug.cs.

◆ Close()

static void System.Diagnostics.Debug.Close ( )
static

Flushes the output buffer and then calls the Close method on each of the P:System.Diagnostics.Debug.Listeners.

Definition at line 77 of file Debug.cs.

◆ Fail() [1/2]

static void System.Diagnostics.Debug.Fail ( string  message)
static

Emits the specified error message.

Parameters
messageA message to emit.

Definition at line 128 of file Debug.cs.

◆ Fail() [2/2]

static void System.Diagnostics.Debug.Fail ( string  message,
string  detailMessage 
)
static

Emits an error message and a detailed error message.

Parameters
messageA message to emit.
detailMessageA detailed message to emit.

Definition at line 138 of file Debug.cs.

◆ Flush()

static void System.Diagnostics.Debug.Flush ( )
static

Flushes the output buffer and causes buffered data to write to the P:System.Diagnostics.Debug.Listeners collection.

Definition at line 69 of file Debug.cs.

◆ Indent()

static void System.Diagnostics.Debug.Indent ( )
static

Increases the current P:System.Diagnostics.Debug.IndentLevel by one.

Definition at line 337 of file Debug.cs.

◆ Print() [1/2]

static void System.Diagnostics.Debug.Print ( string  message)
static

Writes a message followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
messageThe message to write.

Definition at line 146 of file Debug.cs.

◆ Print() [2/2]

static void System.Diagnostics.Debug.Print ( string  format,
params object []  args 
)
static

Writes a formatted string followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
formatA composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the args array.
argsAn object array containing zero or more objects to format.
Exceptions
T:System.ArgumentNullExceptionformat is null.
T:System.FormatExceptionformat is invalid.-or- The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format.

Definition at line 159 of file Debug.cs.

◆ Unindent()

static void System.Diagnostics.Debug.Unindent ( )
static

Decreases the current P:System.Diagnostics.Debug.IndentLevel by one.

Definition at line 344 of file Debug.cs.

◆ Write() [1/4]

static void System.Diagnostics.Debug.Write ( string  message)
static

Writes a message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
messageA message to write.

Definition at line 168 of file Debug.cs.

◆ Write() [2/4]

static void System.Diagnostics.Debug.Write ( object  value)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.

Definition at line 177 of file Debug.cs.

◆ Write() [3/4]

static void System.Diagnostics.Debug.Write ( string  message,
string  category 
)
static

Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
messageA message to write.
categoryA category name used to organize the output.

Definition at line 187 of file Debug.cs.

◆ Write() [4/4]

static void System.Diagnostics.Debug.Write ( object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.
categoryA category name used to organize the output.

Definition at line 197 of file Debug.cs.

◆ WriteIf() [1/4]

static void System.Diagnostics.Debug.WriteIf ( bool  condition,
string  message 
)
static

Writes a message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the message is written to the trace listeners in the collection.
messageA message to write.

Definition at line 255 of file Debug.cs.

◆ WriteIf() [2/4]

static void System.Diagnostics.Debug.WriteIf ( bool  condition,
object  value 
)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the value is written to the trace listeners in the collection.
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.

Definition at line 265 of file Debug.cs.

◆ WriteIf() [3/4]

static void System.Diagnostics.Debug.WriteIf ( bool  condition,
string  message,
string  category 
)
static

Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the category name and message are written to the trace listeners in the collection.
messageA message to write.
categoryA category name used to organize the output.

Definition at line 276 of file Debug.cs.

◆ WriteIf() [4/4]

static void System.Diagnostics.Debug.WriteIf ( bool  condition,
object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the category name and value are written to the trace listeners in the collection.
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.
categoryA category name used to organize the output.

Definition at line 287 of file Debug.cs.

◆ WriteLine() [1/5]

static void System.Diagnostics.Debug.WriteLine ( string  message)
static

Writes a message followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
messageA message to write.

Definition at line 206 of file Debug.cs.

◆ WriteLine() [2/5]

static void System.Diagnostics.Debug.WriteLine ( object  value)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.

Definition at line 215 of file Debug.cs.

◆ WriteLine() [3/5]

static void System.Diagnostics.Debug.WriteLine ( string  message,
string  category 
)
static

Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
messageA message to write.
categoryA category name used to organize the output.

Definition at line 225 of file Debug.cs.

◆ WriteLine() [4/5]

static void System.Diagnostics.Debug.WriteLine ( object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.
categoryA category name used to organize the output.

Definition at line 235 of file Debug.cs.

◆ WriteLine() [5/5]

static void System.Diagnostics.Debug.WriteLine ( string  format,
params object []  args 
)
static

Writes a formatted message followed by a line terminator to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection.

Parameters
formatA composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the args array.
argsAn object array that contains zero or more objects to format.

Definition at line 245 of file Debug.cs.

◆ WriteLineIf() [1/4]

static void System.Diagnostics.Debug.WriteLineIf ( bool  condition,
string  message 
)
static

Writes a message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the message is written to the trace listeners in the collection.
messageA message to write.

Definition at line 297 of file Debug.cs.

◆ WriteLineIf() [2/4]

static void System.Diagnostics.Debug.WriteLineIf ( bool  condition,
object  value 
)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the value is written to the trace listeners in the collection.
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.

Definition at line 307 of file Debug.cs.

◆ WriteLineIf() [3/4]

static void System.Diagnostics.Debug.WriteLineIf ( bool  condition,
string  message,
string  category 
)
static

Writes a category name and message to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
categoryA category name used to organize the output.

Definition at line 319 of file Debug.cs.

◆ WriteLineIf() [4/4]

static void System.Diagnostics.Debug.WriteLineIf ( bool  condition,
object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Debug.Listeners collection if a condition is true.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the category name and value are written to the trace listeners in the collection.
valueAn object whose name is sent to the P:System.Diagnostics.Debug.Listeners.
categoryA category name used to organize the output.

Definition at line 330 of file Debug.cs.

Property Documentation

◆ AutoFlush

bool System.Diagnostics.Debug.AutoFlush
staticgetset

Gets or sets a value indicating whether M:System.Diagnostics.Debug.Flush should be called on the P:System.Diagnostics.Debug.Listeners after every write.

Returns
true if M:System.Diagnostics.Debug.Flush is called on the P:System.Diagnostics.Debug.Listeners after every write; otherwise, false.

Definition at line 26 of file Debug.cs.

◆ IndentLevel

int System.Diagnostics.Debug.IndentLevel
staticgetset

Gets or sets the indent level.

Returns
The indent level. The default is 0.

Definition at line 42 of file Debug.cs.

◆ IndentSize

int System.Diagnostics.Debug.IndentSize
staticgetset

Gets or sets the number of spaces in an indent.

Returns
The number of spaces in an indent. The default is four.

Definition at line 56 of file Debug.cs.

◆ Listeners

TraceListenerCollection System.Diagnostics.Debug.Listeners
staticget

Gets the collection of listeners that is monitoring the debug output.

Returns
A T:System.Diagnostics.TraceListenerCollection representing a collection of type T:System.Diagnostics.TraceListener that monitors the debug output.

Definition at line 13 of file Debug.cs.


The documentation for this class was generated from the following file: