Debug Class

Definition

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

public static class Debug
Inheritance
Debug

Inherited Members

System.Object

Methods

Assert(Boolean)

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

[Conditional("DEBUG")]
public static void Assert(bool condition)
Parameters
condition
Boolean

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

Attributes

Assert(Boolean, String)

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

[Conditional("DEBUG")]
public static void Assert(bool condition, string message)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the specified message is not sent and the message box is not displayed.

message
String

The message to send to the Listeners collection.

Attributes

Assert(Boolean, String, String)

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

[Conditional("DEBUG")]
public static void Assert(bool condition, string message, string detailMessage)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the specified messages are not sent and the message box is not displayed.

message
String

The message to send to the Listeners collection.

detailMessage
String

The detailed message to send to the Listeners collection.

Attributes

Assert(Boolean, String, String, Object[])

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.

[Conditional("DEBUG")]
public static void Assert(bool condition, string message, string detailMessageFormat, params object[] args)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the specified messages are not sent and the message box is not displayed.

message
String

The message to send to the Listeners collection.

detailMessageFormat
String

The composite format string (see Remarks) to send to the Listeners collection. This message contains text intermixed with zero or more format items, which correspond to objects in the args array.

args
Object[]

An object array that contains zero or more objects to format.

Attributes

Fail(String)

Emits the specified error message.

[Conditional("DEBUG")]
public static void Fail(string message)
Parameters
message
String

A message to emit.

Attributes

Fail(String, String)

Emits an error message and a detailed error message.

[Conditional("DEBUG")]
public static void Fail(string message, string detailMessage)
Parameters
message
String

A message to emit.

detailMessage
String

A detailed message to emit.

Attributes

Write(Object)

Writes the value of the object's ToString() method to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void Write(object value)
Parameters
value
Object

An object whose name is sent to the Listeners.

Attributes

Write(Object, String)

Writes a category name and the value of the object's ToString() method to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void Write(object value, string category)
Parameters
value
Object

An object whose name is sent to the Listeners.

category
String

A category name used to organize the output.

Attributes

Write(String)

Writes a message to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void Write(string message)
Parameters
message
String

A message to write.

Attributes

Write(String, String)

Writes a category name and message to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void Write(string message, string category)
Parameters
message
String

A message to write.

category
String

A category name used to organize the output.

Attributes

WriteIf(Boolean, Object)

Writes the value of the object's ToString() method to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteIf(bool condition, object value)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the value is written to the trace listeners in the collection.

value
Object

An object whose name is sent to the Listeners.

Attributes

WriteIf(Boolean, Object, String)

Writes a category name and the value of the object's ToString() method to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteIf(bool condition, object value, string category)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the category name and value are written to the trace listeners in the collection.

value
Object

An object whose name is sent to the Listeners.

category
String

A category name used to organize the output.

Attributes

WriteIf(Boolean, String)

Writes a message to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteIf(bool condition, string message)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the message is written to the trace listeners in the collection.

message
String

A message to write.

Attributes

WriteIf(Boolean, String, String)

Writes a category name and message to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteIf(bool condition, string message, string category)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the category name and message are written to the trace listeners in the collection.

message
String

A message to write.

category
String

A category name used to organize the output.

Attributes

WriteLine(Object)

Writes the value of the object's ToString() method to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void WriteLine(object value)
Parameters
value
Object

An object whose name is sent to the Listeners.

Attributes

WriteLine(Object, String)

Writes a category name and the value of the object's ToString() method to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void WriteLine(object value, string category)
Parameters
value
Object

An object whose name is sent to the Listeners.

category
String

A category name used to organize the output.

Attributes

WriteLine(String)

Writes a message followed by a line terminator to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void WriteLine(string message)
Parameters
message
String

A message to write.

Attributes

WriteLine(String, Object[])

Writes a formatted message followed by a line terminator to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void WriteLine(string format, params object[] args)
Parameters
format
String

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

args
Object[]

An object array that contains zero or more objects to format.

Attributes

WriteLine(String, String)

Writes a category name and message to the trace listeners in the Listeners collection.

[Conditional("DEBUG")]
public static void WriteLine(string message, string category)
Parameters
message
String

A message to write.

category
String

A category name used to organize the output.

Attributes

WriteLineIf(Boolean, Object)

Writes the value of the object's ToString() method to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteLineIf(bool condition, object value)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the value is written to the trace listeners in the collection.

value
Object

An object whose name is sent to the Listeners.

Attributes

WriteLineIf(Boolean, Object, String)

Writes a category name and the value of the object's ToString() method to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteLineIf(bool condition, object value, string category)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the category name and value are written to the trace listeners in the collection.

value
Object

An object whose name is sent to the Listeners.

category
String

A category name used to organize the output.

Attributes

WriteLineIf(Boolean, String)

Writes a message to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteLineIf(bool condition, string message)
Parameters
condition
Boolean

The conditional expression to evaluate. If the condition is true, the message is written to the trace listeners in the collection.

message
String

A message to write.

Attributes

WriteLineIf(Boolean, String, String)

Writes a category name and message to the trace listeners in the Listeners collection if a condition is true.

[Conditional("DEBUG")]
public static void WriteLineIf(bool condition, string message, string category)
Parameters
condition
Boolean

true to cause a message to be written; otherwise, false.

message
String

A message to write.

category
String

A category name used to organize the output.

Attributes