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
实现

示例

下面的示例创建一个写入控制台屏幕的 @no__t 0。The 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 集合的输出侦听器。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 类提供 @no__t 有关列表信息的属性。The TraceListenerCollection class provides the Count property for information about the list. 它还提供了以下方法: ContainsGetEnumeratorIndexOfIt also provides the following methods: Contains, GetEnumerator, IndexOf.

此类还提供以下方法来修改列表: AddClearInsert 和 @no__t。This 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)

从集合中移除指定索引处的 TraceListenerRemoves from the collection the TraceListener at the specified index.

ToString()

返回一个表示当前对象的 string。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)

TraceListenerCollection 中添加一个跟踪侦听器。Adds 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.

适用于

另请参阅