TraceListenerCollection.Insert(Int32, TraceListener) 方法

定义

将侦听器插入指定的索引位置。Inserts the listener at the specified index.

public:
 void Insert(int index, System::Diagnostics::TraceListener ^ listener);
public void Insert (int index, System.Diagnostics.TraceListener listener);
member this.Insert : int * System.Diagnostics.TraceListener -> unit
Public Sub Insert (index As Integer, listener As TraceListener)

参数

index
Int32

列表中要插入新 TraceListener 的位置。The position in the list to insert the new TraceListener.

listener
TraceListener

要插入列表的 TraceListenerA TraceListener to insert in the list.

例外

index 不是列表中的有效索引。The index is not a valid index in the list.

listenernulllistener is null.

注解

如果索引等于列表中的项数,则侦听器将追加到列表的末尾。If the index equals the number of items in the list, then the listener is appended to the end of the list.

索引是从零开始的。The index is zero-based. 因此,如果要将侦听器插入到第三个位置,则必须调用 myTraceListenerColl.Insert(2, myNewListener)Therefore, if you want to insert the listener into the third position, you must call myTraceListenerColl.Insert(2, myNewListener).

适用于

另请参阅