This documentation is archived and is not being maintained.

CookieCollection.GetEnumerator Method

Gets an enumerator that can iterate through a CookieCollection.

[Visual Basic]
Public Overridable Function GetEnumerator() As IEnumerator _
   Implements IEnumerable.GetEnumerator
public virtual IEnumerator GetEnumerator();
public: virtual IEnumerator* GetEnumerator();
public function GetEnumerator() : IEnumerator;

Return Value

An instance of an implemention of an IEnumerator interface that can iterate through a CookieCollection.




You should use an IEnumerator only to read data in the collection. Enumerators cannot be used to modify the underlying collection. The enumerator does not have exclusive access to the collection.

When an enumerator is created, it takes a snapshot of the current state of the collection. If changes such as adding, modifying, or deleting elements are made to the collection, the snapshot gets out of sync and the enumerator throws an InvalidOperationException. Two enumerators created from the same collection at the same time can produce different snapshots of the collection.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

CookieCollection Class | CookieCollection Members | System.Net Namespace