Bewerken

Share via


SessionStateItemCollection.GetEnumerator Method

Definition

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

public:
 override System::Collections::IEnumerator ^ GetEnumerator();
public override System.Collections.IEnumerator GetEnumerator ();
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Overrides Function GetEnumerator () As IEnumerator

Returns

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

Implements

Examples

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

SessionStateItemCollection items = new SessionStateItemCollection();

items["LastName"] = "Wilson";
items["FirstName"] = "Dan";

foreach (string s in items.Keys)
  Response.Write("items[\"" + s + "\"] = " + items[s].ToString() + "<br />");
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 />")
Next

Applies to

See also