NameObjectCollectionBase.KeysCollection NameObjectCollectionBase.KeysCollection NameObjectCollectionBase.KeysCollection NameObjectCollectionBase.KeysCollection Class

定义

表示集合的 String 键的集合。Represents a collection of the String keys of a collection.

public: ref class NameObjectCollectionBase::KeysCollection : System::Collections::ICollection
[System.Serializable]
public class NameObjectCollectionBase.KeysCollection : System.Collections.ICollection
type NameObjectCollectionBase.KeysCollection = class
    interface ICollection
    interface IEnumerable
Public Class NameObjectCollectionBase.KeysCollection
Implements ICollection
继承
NameObjectCollectionBase.KeysCollectionNameObjectCollectionBase.KeysCollectionNameObjectCollectionBase.KeysCollectionNameObjectCollectionBase.KeysCollection
属性
实现

属性

Count Count Count Count

获取 NameObjectCollectionBase.KeysCollection 中的键数。Gets the number of keys in the NameObjectCollectionBase.KeysCollection.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取集合中指定索引处的项。Gets the entry at the specified index of the collection.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Get(Int32) Get(Int32) Get(Int32) Get(Int32)

获取集合的指定索引处的键。Gets the key at the specified index of the collection.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回循环访问 NameObjectCollectionBase.KeysCollection 的枚举数。Returns an enumerator that iterates through the NameObjectCollectionBase.KeysCollection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

从目标数组的指定索引处开始将整个 NameObjectCollectionBase.KeysCollection 复制到兼容的一维 ArrayCopies the entire NameObjectCollectionBase.KeysCollection to a compatible one-dimensional Array, starting at the specified index of the target array.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

获取一个值,该值指示是否同步对 NameObjectCollectionBase.KeysCollection 的访问(线程安全)。Gets a value indicating whether access to the NameObjectCollectionBase.KeysCollection is synchronized (thread safe).

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

获取可用于同步对 NameObjectCollectionBase.KeysCollection 的访问的对象。Gets an object that can be used to synchronize access to the NameObjectCollectionBase.KeysCollection.

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

线程安全性

此类型的Shared公共静态 (在 Visual Basic) 成员是线程安全的。Public static (Shared in Visual Basic) members of this type are thread safe. 但不保证所有实例成员都是线程安全的。Any instance members are not guaranteed to be thread safe.

此实现不提供的同步 (线程安全) 包装NameObjectCollectionBase.KeysCollection器, 但派生类可以使用SyncRoot属性创建其自身的NameObjectCollectionBase.KeysCollection同步版本。This implementation does not provide a synchronized (thread safe) wrapper for a NameObjectCollectionBase.KeysCollection, but derived classes can create their own synchronized versions of the NameObjectCollectionBase.KeysCollection using the SyncRoot property.

枚举整个集合本质上不是一个线程安全的过程。Enumerating through a collection is intrinsically not a thread-safe procedure. 即使某个集合已同步,其他线程仍可以修改该集合,这会导致枚举数引发异常。Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. 若要确保枚举过程中的线程安全性,可以在整个枚举期间锁定集合,或者捕获由其他线程进行的更改所导致的异常。To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.