SessionStateItemCollection.Item Property (Int32)

 

Gets or sets a value in the collection by numerical index.

Namespace:   System.Web.SessionState
Assembly:  System.Web (in System.Web.dll)

Public Property Item (
	index As Integer
) As Object

Parameters

index
Type: System.Int32

The numerical index of the value in the collection.

Property Value

Type: System.Object

The value in the collection stored at the specified index. If the specified key is not found, attempting to get it returns null, and attempting to set it creates a new element using the specified key.

The following code example sets and gets values in a SessionStateItemCollection collection by numerical index.

Dim sessionItems As SessionStateItemCollection = New SessionStateItemCollection()

sessionItems("ZipCode") = "98072"
sessionItems("Email") = "someone@example.com"

For i As Integer = 0 To items.Count - 1
  Response.Write("sessionItems(" & i & ") = " & sessionItems(i).ToString() & "<br />")
Next

.NET Framework
Available since 2.0
Return to top
Show: