TraceListenerCollection.Add(TraceListener) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 TraceListener 加入清單中。
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
參數
- listener
- TraceListener
要加入至清單的 TraceListener。
傳回
要插入新接聽程式的位置。
範例
下列範例會 TextWriterTraceListener 建立輸出至主控台畫面的 。 程式代碼接著會將新的接聽程式新增至 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)