This documentation is archived and is not being maintained.

Cache.GetEnumerator Method

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

[Visual Basic]
Public Function GetEnumerator() As IDictionaryEnumerator
public IDictionaryEnumerator GetEnumerator();
public: IDictionaryEnumerator* GetEnumerator();
public function GetEnumerator() : IDictionaryEnumerator;

Return Value

An enumerator to iterate through the Cache object.


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


[Visual Basic, C#] 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.

[Visual Basic] 
Dim CacheEnum As IDictionaryEnumerator = Cache.GetEnumerator()
While CacheEnum.MoveNext()
   cacheItem = Server.HtmlEncode(CacheEnum.Current.Value.ToString())
End While

IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
  cacheItem = Server.HtmlEncode(CacheEnum.Current.ToString()); 

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Cache Class | Cache Members | System.Web.Caching Namespace