SessionStateItemCollection.Keys 属性

定义

为存储在集合中的所有值获取变量名的集合。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

属性值

NameObjectCollectionBase.KeysCollection

包含所有集合键的 NameObjectCollectionBase.KeysCollection 集合。The NameObjectCollectionBase.KeysCollection collection that contains all the collection keys.

实现

示例

下面的代码示例 SessionStateItemCollection 使用属性返回的变量名称获取集合中的变量名称 KeysThe 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

注解

每个键都是一个字符串,它表示集合中存储的值的变量名称。Each key is a string that represents a variable name for a value stored in the collection.

适用于