TextWriterTraceListener Constructor ()
.NET Framework (current version)
Initializes a new instance of the TextWriterTraceListener class with TextWriter as the output recipient.
Assembly: System (in System.dll)
This constructor uses the TextWriter stream as the recipient of the tracing or debugging output. Its Name property is initialized to an empty string ("", or String::Empty).
The following example creates a TextWriterTraceListener using the TextWriterTraceListener() constructor. It sets the Writer property to console output, and then adds the TextWriterTraceListener to the TraceListenerCollection. It writes a message in two segments, and then closes the TextWriterTraceListener.
void main() { #if defined(TRACE) // Create a text writer that writes to the console screen and add // it to the trace listeners. TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener; myWriter->Writer = System::Console::Out; Trace::Listeners->Add( myWriter ); // Write the output to the console screen. myWriter->Write( "Write to the Console screen. " ); myWriter->WriteLine( "Again, write to console screen." ); // Flush and close the output. myWriter->Flush(); myWriter->Close(); #endif }
.NET Framework
Available since 1.1
Available since 1.1
Show: