Bagikan melalui


TraceListenerCollection.Add(TraceListener) Metode

Definisi

TraceListener Menambahkan ke daftar.

public:
 int Add(System::Diagnostics::TraceListener ^ listener);
public int Add (System.Diagnostics.TraceListener listener);
member this.Add : System.Diagnostics.TraceListener -> int
Public Function Add (listener As TraceListener) As Integer

Parameter

listener
TraceListener

untuk TraceListener ditambahkan ke daftar.

Mengembalikan

Posisi di mana pendengar baru dimasukkan.

Contoh

Contoh berikut membuat TextWriterTraceListener output tersebut ke layar konsol. Kode kemudian menambahkan pendengar baru ke Trace.Listeners.

/* Create a listener, which outputs to the console screen, and 
 * add it to the trace listeners. */
TextWriterTraceListener^ myWriter = gcnew TextWriterTraceListener;
myWriter->Writer = System::Console::Out;
Trace::Listeners->Add( myWriter );
/* Create a listener, which outputs to the console screen, and
  * add it to the trace listeners. */
TextWriterTraceListener myWriter = new TextWriterTraceListener();
myWriter.Writer = System.Console.Out;
Trace.Listeners.Add(myWriter);
' Create a listener, which outputs 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)

Berlaku untuk

Lihat juga