SessionStateItemCollection 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
存储在会话状态中的对象的集合。 此类不能被继承。
public ref class SessionStateItemCollection sealed : System::Collections::Specialized::NameObjectCollectionBase, System::Collections::ICollection, System::Web::SessionState::ISessionStateItemCollectionpublic sealed class SessionStateItemCollection : System.Collections.Specialized.NameObjectCollectionBase, System.Collections.ICollection, System.Web.SessionState.ISessionStateItemCollectiontype SessionStateItemCollection = class
    inherit NameObjectCollectionBase
    interface ISessionStateItemCollection
    interface ICollection
    interface IEnumerablePublic NotInheritable Class SessionStateItemCollection
Inherits NameObjectCollectionBase
Implements ICollection, ISessionStateItemCollection- 继承
- 实现
示例
下面的代码示例创建一个新的 SessionStateItemCollection 对象,并按名称设置和获取集合中的值。
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
注解
类 SessionStateItemCollection 用于管理按变量名称或数字索引编制索引的会话状态变量值。 会话状态变量使用 HttpSessionState 类向 ASP.NET 应用程序代码公开,该类是使用 Session 当前 HttpContext 或 的 属性访问的 Page。 类 HttpSessionState 调用 HttpSessionStateContainer 类,该类使用 SessionStateItemCollection管理会话状态变量值。
继承者说明
基于 SessionStateStoreProviderBase 类创建自定义会话状态提供程序时,请使用 SessionStateItemCollection 类来管理会话状态中存储的项。 如果需要创建自定义对象来管理会话状态项,请实现 ISessionStateItemCollection 接口。
构造函数
| SessionStateItemCollection() | 创建一个新的空 SessionStateItemCollection 对象。 | 
属性
| Count | 获取包含在 NameObjectCollectionBase 实例中的键/值对的数目。(继承自 NameObjectCollectionBase) | 
| Dirty | 获取或设置一个值,该值指示是否已将集合标记为“已更改”。 | 
| IsReadOnly | 获取或设置一个值,通过该值指示 NameObjectCollectionBase 实例是否为只读的。(继承自 NameObjectCollectionBase) | 
| Item[Int32] | 按照数字索引获取或设置集合中的值。 | 
| Item[String] | 按名称获取或设置集合中的值。 | 
| Keys | 为存储在集合中的所有值获取变量名的集合。 | 
方法
显式接口实现
| ICollection.CopyTo(Array, Int32) | 从目标数组的指定索引处开始将整个 NameObjectCollectionBase 复制到兼容的一维 Array。(继承自 NameObjectCollectionBase) | 
| ICollection.IsSynchronized | 获取一个值,该值指示对 NameObjectCollectionBase 对象的访问是否同步(线程安全)。(继承自 NameObjectCollectionBase) | 
| ICollection.SyncRoot | 获取一个对象,该对象可用于同步对 NameObjectCollectionBase 对象的访问。(继承自 NameObjectCollectionBase) | 
扩展方法
| Cast<TResult>(IEnumerable) | 将 IEnumerable 的元素强制转换为指定的类型。 | 
| OfType<TResult>(IEnumerable) | 根据指定类型筛选 IEnumerable 的元素。 | 
| AsParallel(IEnumerable) | 启用查询的并行化。 | 
| AsQueryable(IEnumerable) | 将 IEnumerable 转换为 IQueryable。 |