ISessionStateItemCollection.Item[] 屬性

定義

取得或設定集合中的值。

多載

Item[Int32]

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

Item[String]

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

Item[Int32]

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

public:
 property System::Object ^ default[int] { System::Object ^ get(int index); void set(int index, System::Object ^ value); };
public object this[int index] { get; set; }
member this.Item(int) : obj with get, set
Default Public Property Item(index As Integer) As Object

參數

index
Int32

集合中某個值的數值索引。

屬性值

集合中存放於指定索引位置的值。

範例

下列程式碼範例示範屬性的實作 Item[Int32] ,這個屬性會使用 SortedList 來儲存會話變數名稱和值。 如需介面完整實作的 ISessionStateItemCollection 範例,請參閱介面概觀中 ISessionStateItemCollection 提供的範例。

public object this[int index]
{
  get { return pItems[index]; }
  set
  {
    pItems[index] = value;
    pDirty = true;
  }
}
Public Property Item(index As Integer) As Object Implements ISessionStateItemCollection.Item
  Get
    Return pItems(index)
  End Get
  Set
    pItems(index) = value
    pDirty = True
  End Set
End Property

另請參閱

適用於

Item[String]

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

public:
 property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ name); void set(System::String ^ name, System::Object ^ value); };
public object this[string name] { get; set; }
member this.Item(string) : obj with get, set
Default Public Property Item(name As String) As Object

參數

name
String

集合中某個值的索引鍵名稱。

屬性值

集合中此指定名稱的值。

範例

下列程式碼範例示範屬性的實作 Item[String] ,這個屬性會使用 SortedList 來儲存會話變數名稱和值。 如需介面完整實作的 ISessionStateItemCollection 範例,請參閱介面概觀中 ISessionStateItemCollection 提供的範例。

public object this[string name]
{
  get { return pItems[name]; }
  set
  {
    pItems[name] = value;
    pDirty = true;
  }
}
Public Property Item(name As String) As Object Implements ISessionStateItemCollection.Item
  Get
    Return pItems(name)
  End Get
  Set
    pItems(name) = value
    pDirty = True
  End Set
End Property

另請參閱

適用於