TextWriterTraceListener.Write(String) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bu örneğin Writeröğesine bir ileti yazar.
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)
Parametreler
- message
- String
Yazılacak ileti.
Örnekler
Aşağıdaki örnek, konsol ekranına yazmak için adlandırılmış myWriter
bir TextWriterTraceListener uygulama yapar. Örnek, konsol ekranına iki satır yazar. İkinci yazmanın ilk yazma ile aynı satırda göründüğünü unutmayın. Örnek daha sonra akışı boşaltır ve kapatır.
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
Şunlara uygulanır
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin