Rediger

Del via


SessionStateItemCollection.Keys Property

Definition

Gets a collection of the variable names for all values stored in the collection.

public:
 virtual property System::Collections::Specialized::NameObjectCollectionBase::KeysCollection ^ Keys { System::Collections::Specialized::NameObjectCollectionBase::KeysCollection ^ get(); };
public override System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys { get; }
member this.Keys : System.Collections.Specialized.NameObjectCollectionBase.KeysCollection
Public Overrides ReadOnly Property Keys As NameObjectCollectionBase.KeysCollection

Property Value

The NameObjectCollectionBase.KeysCollection collection that contains all the collection keys.

Implements

Examples

The following code example gets the variable names in a SessionStateItemCollection collection using the variable names returned by the Keys property.

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

Remarks

Each key is a string that represents a variable name for a value stored in the collection.

Applies to

See also