Export (0) Print
Expand All

Cache.GetEnumerator Method

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

Namespace:  System.Web.Caching
Assembly:  System.Web (in System.Web.dll)

public IDictionaryEnumerator GetEnumerator()

Return Value

Type: System.Collections.IDictionaryEnumerator
An enumerator to iterate through the Cache object.

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

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);
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft