TraceListenerCollection 類別

定義

提供 TraceListener 物件的安全執行緒清單。Provides a thread-safe list of TraceListener objects.

public ref class TraceListenerCollection : System::Collections::IList
public class TraceListenerCollection : System.Collections.IList
type TraceListenerCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class TraceListenerCollection
Implements IList
繼承
TraceListenerCollection
實作

範例

下列範例會建立寫入主控台畫面的 ConsoleTraceListenerThe following example creates a ConsoleTraceListener that writes to the console screen. 然後,此程式碼會將新的接聽程式新增至 Trace.ListenersThe code then adds the new listener to the Trace.Listeners.

// Create a ConsoletTraceListener and add it to the trace listeners.
#if defined(TRACE)
ConsoleTraceListener^ myWriter = gcnew ConsoleTraceListener( );
Trace::Listeners->Add( myWriter );
#endif
/* Create a ConsoleTraceListener and add it to the trace listeners. */
ConsoleTraceListener myWriter = new
   ConsoleTraceListener();
Trace.Listeners.Add(myWriter);

' Create a ConsoleTraceListener and add it to the trace listeners. 
Dim myWriter As New ConsoleTraceListener()
Trace.Listeners.Add(myWriter)

備註

@No__t-0 清單用來指定 Trace.Listeners 和 @no__t 2 集合的輸出接聽項。The TraceListenerCollection list is used to specify the output listeners for the Trace.Listeners and the Debug.Listeners collections. 您無法建立此類別的實例。You cannot create an instance of this class.

這份清單是安全線程,不過用來存取清單和列舉值的方法並不會進行同步處理鎖定。This list is thread-safe, however the methods used to access the list and the enumerator do not take synchronization locks. 相反地,會複製集合、修改複本,並將參考設定為集合的複本。Instead, the collection is copied, the copy is modified, and a reference is set to the copy of the collection. @No__t-0、RemoveClear 之類的方法會修改集合中的元素。Methods like Add, Remove, and Clear modify the elements in the collection.

@No__t-0 類別提供此清單相關資訊的 Count 屬性。The TraceListenerCollection class provides the Count property for information about the list. 它也提供下列方法: ContainsGetEnumeratorIndexOfIt also provides the following methods: Contains, GetEnumerator, IndexOf.

這個類別也提供下列方法來修改清單: AddClearInsertRemoveThis class also provides the following methods to modify the list: Add, Clear, Insert, and Remove. @No__t-0 方法會將清單的一部分複製到陣列。The CopyTo method copies a part of the list to an array. @No__t-0 方法會在指定的索引編號刪除清單成員。The RemoveAt method deletes the list member at a specified index number.

屬性

Count

取得清單中的接聽項數目。Gets the number of listeners in the list.

Item[Int32]

取得或設定在指定索引處的 TraceListenerGets or sets the TraceListener at the specified index.

Item[String]

取得清單中具有指定名稱的第一個 TraceListenerGets the first TraceListener in the list with the specified name.

方法

Add(TraceListener)

TraceListener 加入清單中。Adds a TraceListener to the list.

AddRange(TraceListener[])

TraceListener 物件陣列加入清單。Adds an array of TraceListener objects to the list.

AddRange(TraceListenerCollection)

將另一個 TraceListenerCollection 的內容加入清單。Adds the contents of another TraceListenerCollection to the list.

Clear()

清除清單中所有的接聽項。Clears all the listeners from the list.

Contains(TraceListener)

檢查清單是否包含指定的接聽項。Checks whether the list contains the specified listener.

CopyTo(TraceListener[], Int32)

將目前的 TraceListenerCollection 清單區段複製到指定索引的指定陣列。Copies a section of the current TraceListenerCollection list to the specified array at the specified index.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()

取得這個清單的列舉值。Gets an enumerator for this list.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(TraceListener)

取得指定接聽項的索引。Gets the index of the specified listener.

Insert(Int32, TraceListener)

在指定索引插入接聽項。Inserts the listener at the specified index.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(String)

從集合中移除具有指定名稱的第一個 TraceListenerRemoves from the collection the first TraceListener with the specified name.

Remove(TraceListener)

從集合中移除指定的 TraceListenerRemoves from the collection the specified TraceListener.

RemoveAt(Int32)

將在指定索引的 TraceListener 從集合中移除。Removes from the collection the TraceListener at the specified index.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

複製目前 TraceListenerCollection 的區段至 TraceListener 物件之指定的陣列。Copies a section of the current TraceListenerCollection to the specified array of TraceListener objects.

ICollection.IsSynchronized

取得值,這個值表示對 TraceListenerCollection 的存取是否同步 (安全執行緒)。Gets a value indicating whether access to the TraceListenerCollection is synchronized (thread safe).

ICollection.SyncRoot

取得可用以同步存取 TraceListenerCollection 的物件。Gets an object that can be used to synchronize access to the TraceListenerCollection.

IList.Add(Object)

加入追蹤接聽程式至 TraceListenerCollectionAdds a trace listener to the TraceListenerCollection.

IList.Contains(Object)

判斷 TraceListenerCollection 是否含有特定物件。Determines whether the TraceListenerCollection contains a specific object.

IList.IndexOf(Object)

判斷 TraceListenerCollection 中特定物件的索引。Determines the index of a specific object in the TraceListenerCollection.

IList.Insert(Int32, Object)

TraceListener 物件插入 TraceListenerCollection 中的指定位置。Inserts a TraceListener object at the specified position in the TraceListenerCollection.

IList.IsFixedSize

取得值,指出 TraceListenerCollection 是否有固定的大小。Gets a value indicating whether the TraceListenerCollection has a fixed size.

IList.IsReadOnly

取得值,指出 TraceListenerCollection 是否唯讀。Gets a value indicating whether the TraceListenerCollection is read-only.

IList.Item[Int32]

取得或設定位於 TraceListener 中指定索引處的 TraceListenerCollectionGets or sets the TraceListener at the specified index in the TraceListenerCollection.

IList.Remove(Object)

TraceListenerCollection 移除物件。Removes an object from the TraceListenerCollection.

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱