TraceListenerCollection.Add(TraceListener) TraceListenerCollection.Add(TraceListener) TraceListenerCollection.Add(TraceListener) TraceListenerCollection.Add(TraceListener) Method

Definizione

Aggiunge un oggetto TraceListener all'elenco.Adds a TraceListener to the list.

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

Parametri

listener
TraceListener TraceListener TraceListener TraceListener

Oggetto TraceListener da aggiungere all'elenco.A TraceListener to add to the list.

Restituisce

Posizione in cui il nuovo listener è stato inserito.The position at which the new listener was inserted.

Esempi

L'esempio seguente crea un TextWriterTraceListener che invia un output allo schermo della console.The following example creates a TextWriterTraceListener that outputs to the console screen. Il codice aggiunge quindi il nuovo listener per il Trace.Listeners.The code then adds the new listener to the 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)

Si applica a

Vedi anche