System.Diagnostics.Trace.WriteIf Method

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

Syntax

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

Parameters

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

Remarks

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

This method calls the TraceListener.Write(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