다음을 통해 공유


TextWriterTraceListener.WriteLine(String) 메서드

정의

줄 종결자가 뒤에 오는 이 인스턴스의 Writer에 메시지를 씁니다. 기본 줄 종결자는 캐리지 리턴과 줄 바꿈(\r\n) 조합입니다.

public:
 override void WriteLine(System::String ^ message);
public override void WriteLine (string? message);
public override void WriteLine (string message);
override this.WriteLine : string -> unit
Public Overrides Sub WriteLine (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 the Console screen. " );
   myWriter->WriteLine( "Again, write to console screen." );
   
   // Flush and close the output.
   myWriter->Flush();
   myWriter->Close();
   #endif
}
public class Sample
{
    public static 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 the Console screen. ");
        myWriter.WriteLine("Again, write to 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 the Console screen. ")
        myWriter.WriteLine("Again, write to console screen.")
        
        ' Flush and close the output.
        myWriter.Flush()
        myWriter.Close()
    End Sub

End Class

적용 대상

추가 정보