Прочетете на английски Редактиране

Споделяне чрез


SessionStateItemCollection Constructor

Definition

Creates a new, empty SessionStateItemCollection object.

C#
public SessionStateItemCollection();

Examples

The following code example creates a new SessionStateItemCollection object and sets and gets values in the collection by name.

C#
SessionStateItemCollection items = new SessionStateItemCollection();

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

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

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

Продукт Версии
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also