SessionStateItemCollection.GetEnumerator Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Returns an enumerator that can be used to read all the key names in the collection.

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

Public Overrides Function GetEnumerator As IEnumerator

Return Value

Type: System.Collections.IEnumerator

An IEnumerator that can iterate through the variable names in the session-state collection.

The following code example gets the variable names in a SessionStateItemCollection collection using the GetEnumerator method.

Dim items As SessionStateItemCollection = New SessionStateItemCollection()

items("LastName") = "Wilson"
items("FirstName") = "Dan"

For Each s As String In items.Keys
  Response.Write("items(""" & s & """) = " & items(s).ToString() & "<br />")

.NET Framework
Available since 2.0
Return to top