TextWriterTraceListener.Write Method (String)
Writes a message to this instance's Writer.
[Visual Basic] Overrides Overloads Public Sub Write( _ ByVal message As String _ ) [C#] public override void Write( string message ); [C++] public: void Write( String* message ); [JScript] public override function Write( message : String );
Parameters
- message
- A message to write.
Example
[Visual Basic, C#, C++] The following example implements a TextWriterTraceListener named myWriter to write to the console screen. The example writes two lines to the console screen. Note the second write appears on the same line as the first write. The example then flushes and closes the stream.
[Visual Basic] Public Class Sample Public Shared Sub Main() ' Create a text writer that writes to the console screen and add ' it to the trace listeners Dim myWriter As New TextWriterTraceListener() myWriter.Writer = System.Console.Out Trace.Listeners.Add(myWriter) ' Write the output to the console screen. myWriter.Write("Write to console screen. ") myWriter.WriteLine("Again, write to the Console screen.") ' Flush and close the output. myWriter.Flush() myWriter.Close() End Sub End Class [C#] public class Sample { void Main(string[] args) { /* Create a text writer that writes to the console screen and add * it to the trace listeners */ TextWriterTraceListener myWriter = new TextWriterTraceListener(); myWriter.Writer = System.Console.Out; Trace.Listeners.Add(myWriter); // Write the output to the console screen. myWriter.Write("Write to console screen. "); myWriter.WriteLine("Again, write to the Console screen."); // Flush and close the output. myWriter.Flush(); myWriter.Close(); } } [C++] int main() { /* Create a text writer that writes to the console screen and add * it to the trace listeners */ TextWriterTraceListener* myWriter = new TextWriterTraceListener(); myWriter->Writer = System::Console::Out; Trace::Listeners->Add(myWriter); // Write the output to the console screen. myWriter->Write(S"Write to console screen. "); myWriter->WriteLine(S"Again, write to the Console screen."); // Flush and close the output. myWriter->Flush(); myWriter->Close(); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
TextWriterTraceListener Class | TextWriterTraceListener Members | System.Diagnostics Namespace | TextWriterTraceListener.Write Overload List | TraceListener | DefaultTraceListener | EventLogTraceListener | TextWriterTraceListener | Stream | TextWriter | Debug | Trace