다음을 통해 공유


TextWriterTraceListener.Write(String) 메서드

정의

이 인스턴스의 Writer에 메시지를 씁니다.

public:
 override void Write(System::String ^ message);
public override void Write (string? message);
public override void Write (string message);
override this.Write : string -> unit
Public Overrides Sub Write (message As String)

매개 변수

message
String

쓸 메시지입니다.

예제

다음 예제에서는 TextWriterTraceListenermyWriter 라는 를 구현하여 콘솔 화면에 씁니다. 이 예제에서는 콘솔 화면에 두 줄을 씁니다. 두 번째 쓰기는 첫 번째 쓰기와 동일한 줄에 나타납니다. 그런 다음, 스트림을 플러시하고 닫습니다.

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 console screen. " );
   myWriter->WriteLine( "Again, write to the Console screen." );
   
   // Flush and close the output.
   myWriter->Flush();
   myWriter->Close();
   #endif
}
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();
 }
}
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

적용 대상

추가 정보