MemoryCache.GetEnumerator 方法

定义

创建一个枚举器,它可用于循环访问缓存项的集合。Creates an enumerator that can be used to iterate through a collection of cache entries.

protected:
 override System::Collections::Generic::IEnumerator<System::Collections::Generic::KeyValuePair<System::String ^, System::Object ^>> ^ GetEnumerator();
protected override System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string,object>> GetEnumerator ();
override this.GetEnumerator : unit -> System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, obj>>
Protected Overrides Function GetEnumerator () As IEnumerator(Of KeyValuePair(Of String, Object))

返回

IEnumerator<KeyValuePair<String,Object>>

可提供对缓存中的项的访问的枚举器对象。The enumerator object that provides access to the items in the cache.

注解

方法返回的枚举数 GetEnumerator 可用于循环访问缓存中的项。The enumerator that is returned by the GetEnumerator method can be used to iterate over entries in the cache.

重要

检索实例的枚举器 MemoryCache 是消耗大量资源的操作。Retrieving an enumerator for a MemoryCache instance is a resource-intensive and blocking operation. 因此,不应在生产应用程序中使用枚举器。Therefore, the enumerator should not be used in production applications.

适用于