KeyContainerPermissionAccessEntryEnumerator 类

定义

注意

Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}

public ref class KeyContainerPermissionAccessEntryEnumerator sealed : System::Collections::IEnumerator
public sealed class KeyContainerPermissionAccessEntryEnumerator : System.Collections.IEnumerator
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class KeyContainerPermissionAccessEntryEnumerator : System.Collections.IEnumerator
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class KeyContainerPermissionAccessEntryEnumerator : System.Collections.IEnumerator
type KeyContainerPermissionAccessEntryEnumerator = class
    interface IEnumerator
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type KeyContainerPermissionAccessEntryEnumerator = class
    interface IEnumerator
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type KeyContainerPermissionAccessEntryEnumerator = class
    interface IEnumerator
Public NotInheritable Class KeyContainerPermissionAccessEntryEnumerator
Implements IEnumerator
继承
KeyContainerPermissionAccessEntryEnumerator
属性
实现

注解

枚举器仅允许读取集合中的数据。Enumerators allow only reading the data in the collection. 枚举器不能用于修改基础集合。Enumerators cannot be used to modify the underlying collection.

最初,枚举数定位在集合中第一个元素的前面。Initially, the enumerator is positioned before the first element in the collection. Reset方法还将枚举器恢复到此位置。The Reset method also brings the enumerator back to this position. 在此位置,调用 Current 属性会引发异常。At this position, calling the Current property throws an exception. 因此,在 MoveNext 读取属性的值之前,必须调用方法以将枚举数前移到集合的第一个元素 CurrentTherefore, you must call the MoveNext method to advance the enumerator to the first element of the collection before reading the value of the Current property.

在调用 CurrentMoveNext 之前,Reset 返回同一对象。Current returns the same object until either MoveNext or Reset is called. MoveNextCurrent 设置为下一个元素。MoveNext sets Current to the next element.

在传递到集合的末尾之后,枚举数放在集合中最后一个元素后面,且调用 MoveNext 会返回 falseAfter the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling MoveNext returns false. 如果最后一次调用 MoveNext 返回 false ,则调用会 Current 引发异常。If the last call to MoveNext returned false, calling Current throws an exception. 若要重置 Current 为集合的第一个元素,请调用, Reset 然后调用 MoveNextTo reset Current to the first element of the collection, call Reset followed by a call to MoveNext.

只要集合保持不变,枚举器就仍有效。An enumerator remains valid as long as the collection remains unchanged. 如果对集合所做的更改(如添加、修改或删除元素),则枚举器将失效且不可恢复,并且对或的下一个调用将 MoveNext Reset 引发 InvalidOperationExceptionIf changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to MoveNext or Reset throws an InvalidOperationException. 如果在调用和之间修改了集合,则将 MoveNext Current Current 返回当前设置它的元素,即使枚举器已失效。If the collection is modified between calling MoveNext and Current, Current returns the element to which it is currently set, even if the enumerator is already invalidated.

枚举数没有对集合的独占访问权;因此,从头到尾对一个集合进行枚举在本质上不是一个线程安全的过程。The enumerator does not have exclusive access to the collection; therefore, 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.

构造函数

KeyContainerPermissionAccessEntryEnumerator()

初始化 KeyContainerPermissionAccessEntryEnumerator 类的新实例。Initializes a new instance of the KeyContainerPermissionAccessEntryEnumerator class.

属性

Current

获取集合中的当前项。Gets the current entry in the collection.

方法

Equals(Object)

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

(继承自 Object)
GetHashCode()

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

(继承自 Object)
GetType()

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

(继承自 Object)
MemberwiseClone()

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

(继承自 Object)
MoveNext()

移至集合中的下一元素。Moves to the next element in the collection.

Reset()

将枚举数重置到集合的开头。Resets the enumerator to the beginning of the collection.

ToString()

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

(继承自 Object)

显式接口实现

IEnumerator.Current

获取集合中的当前对象。Gets the current object in the collection.

适用于