編輯

共用方式為


Cache.GetEnumerator Method

Definition

Retrieves a dictionary enumerator used to iterate through the key settings and their values contained in the cache.

public:
 System::Collections::IDictionaryEnumerator ^ GetEnumerator();
public System.Collections.IDictionaryEnumerator GetEnumerator ();
member this.GetEnumerator : unit -> System.Collections.IDictionaryEnumerator
Public Function GetEnumerator () As IDictionaryEnumerator

Returns

An enumerator to iterate through the Cache object.

Examples

The following example creates an IDictionaryEnumerator object, CacheEnum, using the GetEnumerator method. The enumerator moves through the cache, converts the value of each cached item to a string, and then writes the values to a Web Forms page.

IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
  cacheItem = Server.HtmlEncode(CacheEnum.Current.ToString()); 
  Response.Write(cacheItem);
}
Dim CacheEnum As IDictionaryEnumerator = Cache.GetEnumerator()
While CacheEnum.MoveNext()
   cacheItem = Server.HtmlEncode(CacheEnum.Current.Value.ToString())
   Response.Write(cacheItem)
End While

Remarks

Items can be added to or removed from the cache while this method is enumerating through the items.

Applies to