SessionStateItemCollection Class

SessionStateItemCollection Class

 

A collection of objects stored in session state. This class cannot be inherited.

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

System.Object
  System.Collections.Specialized.NameObjectCollectionBase
    System.Web.SessionState.SessionStateItemCollection

public sealed class SessionStateItemCollection : NameObjectCollectionBase, 
	ISessionStateItemCollection, ICollection, IEnumerable

NameDescription
System_CAPS_pubmethodSessionStateItemCollection()

Creates a new, empty SessionStateItemCollection object.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of key/value pairs contained in the NameObjectCollectionBase instance.(Inherited from NameObjectCollectionBase.)

System_CAPS_pubpropertyDirty

Gets or sets a value indicating whether the collection has been marked as changed.

System_CAPS_pubpropertyItem[Int32]

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

System_CAPS_pubpropertyItem[String]

Gets or sets a value in the collection by name.

System_CAPS_pubpropertyKeys

Gets a collection of the variable names for all values stored in the collection.(Overrides NameObjectCollectionBase.Keys.)

NameDescription
System_CAPS_pubmethodClear()

Removes all values and keys from the session-state collection.

System_CAPS_pubmethodSystem_CAPS_staticDeserialize(BinaryReader)

Creates a SessionStateItemCollection collection from a storage location that is written to using the Serialize method.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Returns an enumerator that can be used to read all the key names in the collection.(Overrides NameObjectCollectionBase.GetEnumerator().)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

Implements the ISerializable interface and returns the data needed to serialize the NameObjectCollectionBase instance.(Inherited from NameObjectCollectionBase.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodOnDeserialization(Object)

Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.(Inherited from NameObjectCollectionBase.)

System_CAPS_pubmethodRemove(String)

Deletes an item from the collection.

System_CAPS_pubmethodRemoveAt(Int32)

Deletes an item at a specified index from the collection.

System_CAPS_pubmethodSerialize(BinaryWriter)

Writes the contents of the collection to a BinaryWriter.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.CopyTo(Array, Int32)

Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.(Inherited from NameObjectCollectionBase.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe).(Inherited from NameObjectCollectionBase.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

Gets an object that can be used to synchronize access to the NameObjectCollectionBase object.(Inherited from NameObjectCollectionBase.)

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

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.

Notes to Implementers:

When you create a custom session-state provider based on the SessionStateStoreProviderBase class, use the SessionStateItemCollection class to manage the items stored in session state. If you need to create a custom object to manage session-state items, implement the ISessionStateItemCollection interface.

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 />");

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft