SessionStateItemCollection.Item Property (Int32)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

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

public object this[
	int index
] { get; set; }

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.

SessionStateItemCollection sessionItems = new SessionStateItemCollection();

sessionItems["ZipCode"] = "98072";
sessionItems["Email"] = "someone@example.com";

for (int i = 0; i < items.Count; i++)
  Response.Write("sessionItems[" + i + "] = " + sessionItems[i].ToString() + "<br />");

.NET Framework
Available since 2.0
Return to top
Show: