Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Item Property (String)
Collapse the table of content
Expand the table of content

SessionStateItemCollection.Item Property (String)

Gets or sets a value in the collection by name.

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

public Object this[
	string name
] { get; set; }

Parameters

name
Type: System.String

The key name of the value in the collection.

Property Value

Type: System.Object
The value in the collection with the specified name. 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.

Implements

ISessionStateItemCollection.Item

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

SessionStateItemCollection items = new SessionStateItemCollection();

items["LastName"] = "Wilson";
items["FirstName"] = "Dan";

foreach (string s in items.Keys)
  Response.Write("items[\"" + s + "\"] = " + items[s].ToString() + "<br />");

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft