System.Diagnostics.Debug.WriteLineIf Method

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

Syntax

[System.Diagnostics.Conditional("DEBUG")]
public static void WriteLineIf (bool condition, string message)

Parameters

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

Remarks

By default, the output is written to an instance of System.Diagnostics.DefaultTraceListener.

This method calls the TraceListener.WriteLine(string) method of the trace listener.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0