共用方式為


SessionStateItemCollection.Keys 屬性

定義

取得由集合中所有值的變數名稱組成的集合。

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 集合,包含所有集合索引鍵。

實作

範例

下列程式代碼範例會使用 屬性傳回的Keys變數名稱,取得集合中的SessionStateItemCollection變數名稱。

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

備註

每個索引鍵都是字串,代表儲存在集合中值的變數名稱。

適用於

另請參閱