SessionStateItemCollection 類別

定義

儲存在工作階段狀態中的物件集合。 此類別無法獲得繼承。

public ref class SessionStateItemCollection sealed : System::Collections::Specialized::NameObjectCollectionBase, System::Collections::ICollection, System::Web::SessionState::ISessionStateItemCollection
public sealed class SessionStateItemCollection : System.Collections.Specialized.NameObjectCollectionBase, System.Collections.ICollection, System.Web.SessionState.ISessionStateItemCollection
type SessionStateItemCollection = class
    inherit NameObjectCollectionBase
    interface ISessionStateItemCollection
    interface ICollection
    interface IEnumerable
Public NotInheritable Class SessionStateItemCollection
Inherits NameObjectCollectionBase
Implements ICollection, ISessionStateItemCollection
繼承
SessionStateItemCollection
實作

範例

下列程式碼範例會建立新的 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

備註

類別 SessionStateItemCollection 是用來管理以變數名稱或數值索引編制索引的會話狀態變數值。 會話狀態變數會公開至使用 類別 ASP.NET 應用程式程式碼,而此類別是使用 HttpSessionStateSession 目前 HttpContextPage 的 屬性來存取。 類別 HttpSessionState 會呼叫 HttpSessionStateContainer 類別,其會使用 SessionStateItemCollection 來管理會話狀態變數值。

給繼承者的注意事項

當您根據 SessionStateStoreProviderBase 類別建立自訂會話狀態提供者時,請使用 SessionStateItemCollection 類別來管理儲存在會話狀態中的專案。 如果您需要建立自訂物件來管理會話狀態專案,請實作 ISessionStateItemCollection 介面。

建構函式

SessionStateItemCollection()

建立新的空白 SessionStateItemCollection 物件。

屬性

Count

取得 NameObjectCollectionBase 執行個體中包含的索引鍵/值組數目。

(繼承來源 NameObjectCollectionBase)
Dirty

取得或設定值,這個值表示集合是否標示為已變更。

IsReadOnly

取得或設定值,表示 NameObjectCollectionBase 執行個體是否為唯讀。

(繼承來源 NameObjectCollectionBase)
Item[Int32]

根據數字索引取得或設定集合中的值。

Item[String]

根據名稱取得或設定集合中的值。

Keys

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

方法

BaseAdd(String, Object)

將具有指定索引鍵和值的項目加入 NameObjectCollectionBase 執行個體。

(繼承來源 NameObjectCollectionBase)
BaseClear()

將所有項目從 NameObjectCollectionBase 執行個體中移除。

(繼承來源 NameObjectCollectionBase)
BaseGet(Int32)

取得 NameObjectCollectionBase 執行個體指定索引處之項目的值。

(繼承來源 NameObjectCollectionBase)
BaseGet(String)

NameObjectCollectionBase 執行個體取得具有指定索引鍵之第一個項目的值。

(繼承來源 NameObjectCollectionBase)
BaseGetAllKeys()

傳回 String 陣列,其中包含 NameObjectCollectionBase 執行個體中的所有索引鍵。

(繼承來源 NameObjectCollectionBase)
BaseGetAllValues()

傳回 Object 陣列,其中包含 NameObjectCollectionBase 執行個體中的所有值。

(繼承來源 NameObjectCollectionBase)
BaseGetAllValues(Type)

傳回指定類型的陣列,其中包含 NameObjectCollectionBase 執行個體中的所有值。

(繼承來源 NameObjectCollectionBase)
BaseGetKey(Int32)

取得 NameObjectCollectionBase 執行個體指定索引處之項目的索引鍵。

(繼承來源 NameObjectCollectionBase)
BaseHasKeys()

取得值,表示 NameObjectCollectionBase 執行個體是否包含其索引鍵不是 null 的項目。

(繼承來源 NameObjectCollectionBase)
BaseRemove(String)

將具有指定索引鍵的項目從 NameObjectCollectionBase 中移除。

(繼承來源 NameObjectCollectionBase)
BaseRemoveAt(Int32)

移除 NameObjectCollectionBase 執行個體指定索引處的項目。

(繼承來源 NameObjectCollectionBase)
BaseSet(Int32, Object)

設定 NameObjectCollectionBase 執行個體指定索引處之項目的值。

(繼承來源 NameObjectCollectionBase)
BaseSet(String, Object)

設定 NameObjectCollectionBase 執行個體中具有指定索引鍵之第一個項目的值 (如果有找到),否則將具有指定索引鍵和值的項目加入 NameObjectCollectionBase 執行個體。

(繼承來源 NameObjectCollectionBase)
Clear()

將工作階段狀態集合中的所有值和索引鍵全部移除。

Deserialize(BinaryReader)

從使用 SessionStateItemCollection 方法所寫入的儲存位置,建立 Serialize(BinaryWriter) 集合。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

傳回列舉值,可用於讀取集合中的所有索引鍵名稱。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)
已淘汰.

實作 ISerializable 介面,並傳回序列化 NameObjectCollectionBase 執行個體所需的資料。

(繼承來源 NameObjectCollectionBase)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnDeserialization(Object)

實作 ISerializable 介面,並於還原序列化完成時引發還原序列化事件。

(繼承來源 NameObjectCollectionBase)
Remove(String)

從集合中刪除項目。

RemoveAt(Int32)

從集合中刪除指定索引處的項目。

Serialize(BinaryWriter)

將集合的內容寫入 BinaryWriter

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從目標陣列的指定索引開始,將整個 NameObjectCollectionBase 複製到相容的一維 Array

(繼承來源 NameObjectCollectionBase)
ICollection.IsSynchronized

取得值,表示是否要同步處理 (執行緒安全) 對 NameObjectCollectionBase 物件的存取。

(繼承來源 NameObjectCollectionBase)
ICollection.SyncRoot

取得可用來同步處理對 NameObjectCollectionBase 物件之存取的物件。

(繼承來源 NameObjectCollectionBase)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱