Writes information about the debug to the trace listeners in the Listeners collection.
Writes the value of the object's ToString method to the trace listeners in the Listeners collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Sub WriteLine(Object)
[C#] public static void WriteLine(object);
[C++] public: static void WriteLine(Object*);
[JScript] public static function WriteLine(Object);
Writes a message followed by a line terminator to the trace listeners in the Listeners collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Sub WriteLine(String)
[C#] public static void WriteLine(string);
[C++] public: static void WriteLine(String*);
[JScript] public static function WriteLine(String);
Writes a category name and the value of the object's ToString method to the trace listeners in the Listeners collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Sub WriteLine(Object, String)
[C#] public static void WriteLine(object, string);
[C++] public: static void WriteLine(Object*, String*);
[JScript] public static function WriteLine(Object, String);
Writes a category name and message to the trace listeners in the Listeners collection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Sub WriteLine(String, String)
[C#] public static void WriteLine(string, string);
[C++] public: static void WriteLine(String*, String*);
[JScript] public static function WriteLine(String, String);
[Visual Basic, C#, JScript] The following example creates a TraceSwitch named generalSwitch. This switch is set outside of the code sample.
[Visual Basic, C#, JScript] If the switch is set to the TraceLevel Error or higher, the example outputs the first error message to the Listeners. For information on adding a listener to the Listeners collection, see the TraceListenerCollection class.
[Visual Basic, C#, JScript] Then, if the TraceLevel is set to Verbose, the example outputs the second error message and the category on the same line as the first message. A line terminator follows the second message.
[Visual Basic, C#, JScript] Note This example shows how to use one of the overloaded versions of WriteLine. For other examples that might be available, see the individual overload topics.
[Visual Basic] ' Class-level declaration. ' Create a TraceSwitch. Private Shared generalSwitch As New TraceSwitch("General", "Entire Application") Public Shared Sub MyErrorMethod(category As String) ' Write the message if the TraceSwitch level is set to Error or higher. If generalSwitch.TraceError Then Debug.Write("My error message. ") End If ' Write a second message if the TraceSwitch level is set to Verbose. If generalSwitch.TraceVerbose Then Debug.WriteLine("My second error message.", category) End If End Sub 'MyErrorMethod [C#] // Class-level declaration. // Create a TraceSwitch. static TraceSwitch generalSwitch = new TraceSwitch("General", "Entire Application"); static public void MyErrorMethod(String category) { // Write the message if the TraceSwitch level is set to Error or higher. if(generalSwitch.TraceError) Debug.Write("My error message. "); // Write a second message if the TraceSwitch level is set to Verbose. if(generalSwitch.TraceVerbose) Debug.WriteLine("My second error message.", category); } [JScript] // Class level declaration. // Create a TraceSwitch. static var generalSwitch : TraceSwitch = new TraceSwitch("General", "Entire Application"); static public function MyErrorMethod(category : String) { // Write the message if the TraceSwitch level is set to Error or higher. if(generalSwitch.TraceError) Debug.Write("My error message. "); //Write a second message if the TraceSwitch level is set to Verbose. if(generalSwitch.TraceVerbose) Debug.WriteLine("My second error message.", category); }
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.