Writes a category name and message followed by a line terminator to the trace listeners in the Listeners collection if a condition is true. The default line terminator is a carriage return followed by a line feed ("\r\n").
[Visual Basic] Overloads Public Shared Sub WriteLineIf( _ ByVal condition As Boolean, _ ByVal message As String, _ ByVal category As String _ ) [C#] public static void WriteLineIf( bool condition, string message, string category ); [C++] public: static void WriteLineIf( bool condition, String* message, String* category ); [JScript] public static function WriteLineIf( condition : Boolean, message : String, category : String );
By default, the output is written to the managed code debuggers, the Microsoft.Win32.Interop.Windows.OutputDebugString API and to the Log method.
The category can be used to group output messages.
Notes to Implementers: You can minimize the performance penalty of instrumenting your application by using If...Then statements instead of using WriteIf statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to false you do not call Write. The second example always calls WriteIf, even when mySwitch.TraceError is false and no tracing output is produced. This can result in unnecessary execution of an arbitrarily complex code.
First example.
if(mySwitch.TraceError) Debug.Write("aNumber = " + aNumber + " out of range");
Second example.
Debug.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range");
Debug Class | Debug Members | System.Diagnostics Namespace | Debug.WriteLineIf Overload List | Debug | Trace | BooleanSwitch | TraceSwitch | TraceListener | DefaultTraceListener | ConditionalAttribute | ConditionalAttribute | ConditionalAttribute | ConditionalAttribute