Cache.GetEnumerator Method

Definition

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

C#
public System.Collections.IDictionaryEnumerator GetEnumerator();

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.

C#
IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
  cacheItem = Server.HtmlEncode(CacheEnum.Current.ToString()); 
  Response.Write(cacheItem);
}

Remarks

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

Applies to

Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1