Redigera

Dela via


SessionStateItemCollection Constructor

Definition

Creates a new, empty SessionStateItemCollection object.

public:
 SessionStateItemCollection();
public SessionStateItemCollection ();
Public Sub New ()

Examples

The following code example creates a new SessionStateItemCollection object and sets and gets values in the 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 />");
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

Remarks

The SessionStateItemCollection class is used to manage session-state variable values indexed by a variable name or by numerical index. The session-state variables are exposed to ASP.NET application code using the HttpSessionState class, which is accessed using the Session property of the current HttpContext or the Page. The HttpSessionState class calls the HttpSessionStateContainer class, which manages session-state variable values using the SessionStateItemCollection collection.

Applies to

See also