总结常用几个接口,以及实现它们的类,IDictionary, ICollection, IEnumerable,
    ISerializable, IDeserializationCallback, ICloneable

1,IDictionary 类是键/值对的集合的基接口。

每个元素是一个存储在 DictionaryEntry 对象中的键/值对。

每个关联必须具有非空引用(Visual Basic 中为 Nothing)的唯一键,但关联的值可以为任何对象引用,包括空引用 (Nothing)。IDictionary 接口允许对所包含的键和值进行枚举,但这并不意味着任何特定的排序顺序。

IDictionary 实现有三种类别:只读、固定大小、可变大小。无法修改只读 IDictionary。固定大小的 IDictionary 不允许添加或移除元素,但允许修改现有元素。可变大小的 IDictionary 允许添加、移除和修改元素

实现 IDictionary 的类

说明
BaseChannelObjectWithProperties Provides a base implementation of a channel object that wants to provide a dictionary interface to its properties.
DictionaryBase 为键/值对的强类型集合提供抽象(在 Visual Basic 中为 MustInherit)基类。
Hashtable 表示键/值对的集合,这些键/值对根据键的哈希代码进行组织。
HybridDictionary 在集合较小时,使用 ListDictionary 来实现 IDictionary,然后当集合变大时,切换到 Hashtable
ListDictionary 使用单链接列表实现 IDictionary。建议用于通常包含 10 个或 10 个以下项的集合。
PropertyCollection 包含 DirectoryEntry 的属性。
PropertyDescriptorCollection 表示 PropertyDescriptor 对象的集合。
SortedList 表示键/值对的集合,这些键和值按键排序并可按照键和索引访问。
StateBag 管理 ASP.NET 服务器控件(包括页)的视图状态。无法继承此类。


2,ICollection 接口是 System.Collections 命名空间中类的基接口。

IDictionaryIList 是基于 ICollection 接口的更专用的接口。IDictionary 实现是键/值对的集合,如 Hashtable 类。IList 实现是可被排序且可按照索引访问其成员的值的集合,如 ArrayList 类。

某些集合(如 Queue 类和 Stack 类)限制对其成员的访问,它们直接实现 ICollection 接口。

如果 IDictionary 接口和 IList 接口都不能满足所需集合的要求,则从 ICollection 接口派生新集合类以提高灵活性。

说明
Array 提供创建、操作、搜索和排序数组的方法,因而在公共语言运行库中用作所有数组的基类。
ArrayList 使用大小可按需动态增加的数组实现 IList 接口。
AttributeCollection 表示特性的集合。
BaseChannelObjectWithProperties Provides a base implementation of a channel object that wants to provide a dictionary interface to its properties.
BaseCollection 提供用于在 System.Windows.Forms 命名空间中创建与数据相关的集合的基本功能。
BindingContext 管理从 Control 类继承的任意对象的 BindingManagerBase 对象集合。
BitArray 管理位值的压缩数组,该值表示为布尔值,其中 true 表示位是打开的 (1),false 表示位是关闭的 (0)。
CaptureCollection 表示一个捕获子字符串序列。CaptureCollection 返回由单个捕获组执行的捕获的集合。
CheckedListBox.CheckedIndexCollection 封装 CheckedListBox 中选中的项(包括处于不确定状态的项)的索引集合。
CheckedListBox.CheckedItemCollection 封装 CheckedListBox 控件中选中项(包括处于不确定状态的项)的集合。
CodeNamespaceImportCollection 表示 CodeNamespaceImport 对象的集合。
CollectionBase 为强类型集合提供抽象(在 Visual Basic 中为 MustInherit)基类。
ComboBox.ObjectCollection 表示 ComboBox 中项的集合。
Control.ControlCollection 表示 Control 对象的集合。
ControlCollection 提供使 ASP.NET 服务器控件能够维护其子控件列表的集合容器。
CookieCollection Cookie 类的实例提供集合容器。
DataBindingCollection 为 ASP.NET 服务器控件提供 DataBinding 对象的集合。无法继承此类。
DataColumnMappingCollection 包含 DataColumnMapping 对象的集合。
DataGridColumnCollection DataGridColumn 导出的列对象的集合,这些对象表示 DataGrid 控件中的列。无法继承此类。
DataGridItemCollection 表示 DataGrid 控件中的 DataGridItem 对象的集合。
DataKeyCollection 表示包含数据源中每个记录的键字段的集合。无法继承此类。
DataListItemCollection 表示 DataList 控件中 DataListItem 对象的集合。无法继承此类。
DataTableMappingCollection DataTableMapping 对象的集合。无法继承此类。
DataView 表示用于排序、筛选、搜索、编辑和导航的 DataTable 的可绑定数据的自定义视图。
DataViewManager 包含 DataSet 中每个 DataTable 的默认 DataViewSettingCollection
DataViewSettingCollection 包含 DataSet 中每个 DataTableDataViewSetting 对象的只读集合。
DesignerCollection 表示设计器的集合。
DictionaryBase 为键/值对的强类型集合提供抽象(在 Visual Basic 中为 MustInherit)基类。
EventDescriptorCollection 表示 EventDescriptor 对象的集合。
EventLogEntryCollection 定义 EventLogEntry 实例集合的大小和枚举数。
Evidence 定义组成对安全策略决策的输入的一组信息。无法继承此类。
GridItemCollection 包含 GridItem 对象的集合。
GroupCollection 表示捕获组的集合。GroupCollection 返回单个匹配中的捕获组的集合。
Hashtable 表示键/值对的集合,这些键/值对根据键的哈希代码进行组织。
HtmlTableCellCollection HtmlTableCell 对象的集合,这些对象表示 HtmlTable 控件的一个行中的单元格。无法继承此类。
HtmlTableRowCollection HtmlTableRow 对象的集合,这些对象表示 HtmlTable 控件中的行。无法继承此类。
HttpSessionState 提供对会话状态值以及会话级别设置和生存期管理方法的访问。
HttpStaticObjectsCollection 提供属性为 StaticObjects 的静态对象的集合。
HybridDictionary 在集合较小时,使用 ListDictionary 来实现 IDictionary,然后当集合变大时,切换到 Hashtable
ImageList.ImageCollection 封装 ImageList 中的 Image 对象的集合。
InternalDataCollectionBase 提供用于创建集合的基本功能。
LinkLabel.LinkCollection 表示 LinkLabel 控件内链接的集合。
ListBox.ObjectCollection 代表 ListBox 中项的集合。
ListBox.SelectedIndexCollection 表示这样的集合,该集合包含 ListBox 中选定项的索引。
ListBox.SelectedObjectCollection 表示 ListBox 中选定项的集合。
ListDictionary 使用单链接列表实现 IDictionary。建议用于通常包含 10 个或 10 个以下项的集合。
ListItemCollection 列表控件中的 ListItem 对象的集合。无法继承此类。
ListView.CheckedIndexCollection 表示包含列表视图控件中选中项的索引的集合。
ListView.CheckedListViewItemCollection 表示列表视图控件中选中项的集合。
ListView.ColumnHeaderCollection 表示 ListView 控件中列标头的集合。
ListView.ListViewItemCollection 表示 ListView 控件中项的集合。
ListView.SelectedIndexCollection 表示包含列表视图控件中选定项的索引的集合。
ListView.SelectedListViewItemCollection 表示列表视图控件中选定项的集合。
ListViewItem.ListViewSubItemCollection 表示 ListViewItem 中储存的 ListViewItem.ListViewSubItem 对象的集合。
ManagementObjectCollection 表示通过 WMI 检索到的管理对象的不同集合。此集合中的对象为从 ManagementBaseObject 派生的类型,包括 ManagementObjectManagementClass

通过 ManagementObjectSearcher 对象执行 WMI 查询,或者通过表示指定类型的 ManagementClass 检索该类型管理对象的枚举,能够得到此集合。此外,这也可能是以指定方式与特定管理对象相关的管理对象集合 — 在这种情况下,此集合可以通过诸如 GetRelated 之类的方法检索到。

此集合可以通过 ManagementObjectCollection.ManagementObjectEnumerator 遍历,并且能够针对各种管理任务对集合中的对象进行检查或操作。

MatchCollection 表示通过以迭代方式将正则表达式模式应用于输入字符串所找到的成功匹配的集合。
Menu.MenuItemCollection 表示 MenuItem 对象的集合。
MethodDataCollection 表示在集合中可用的方法集。
NameObjectCollectionBase 为关联的 String 键和 Object 值的集合(可通过键或索引来访问它)提供抽象(在 Visual Basic 中为 MustInherit)基类。
NameObjectCollectionBase.KeysCollection 表示集合的 String 键的集合。
OdbcErrorCollection 收集 OdbcDataAdapter 生成的所有错误。不能继承此类。
OdbcParameterCollection 表示与 OdbcCommand 相关的参数的集合以及它们各自到 DataSet 中列的映射。无法继承此类。
OleDbErrorCollection 收集用于 OLE DB 的 .NET Framework 数据提供程序生成的所有错误。无法继承此类。
OleDbParameterCollection 表示与 OleDbCommand 相关的参数的集合以及它们各自到 DataSet 中列的映射。
OracleParameterCollection 表示与 OracleCommand 相关的参数的集合以及它们各自到 DataSet 中列的映射。无法继承此类。
PagedDataSource 封装 DataGrid 控件的属性,这些属性使该控件可以执行分页。无法继承此类。
PermissionSet 表示可以包含许多不同类型权限的集合。
PrinterSettings.PaperSizeCollection 包含 PaperSize 对象集合。
PrinterSettings.PaperSourceCollection 包含 PaperSource 对象集合。
PrinterSettings.PrinterResolutionCollection Contains a collection of PrinterResolution objects.
PropertyCollection 包含 DirectoryEntry 的属性。
PropertyDataCollection 表示 WMI 对象的属性集。
PropertyDescriptorCollection 表示 PropertyDescriptor 对象的集合。
PropertyGrid.PropertyTabCollection 包含 PropertyTab 对象集合。
QualifierDataCollection 表示 QualifierData 对象的集合。
Queue 表示对象的先进先出集合。
ReadOnlyCollectionBase 为强类型只读集合提供抽象(在 Visual Basic 中为 MustInherit)基类。
RepeaterItemCollection 表示 Repeater 控件中的 RepeaterItem 对象的集合。无法继承此类。
SchemaNameCollection 包含可以由 DirectoryEntries 对象的 SchemaFilter 属性使用的架构名列表。
SearchResultCollection 包含在 DirectorySearcher 查询过程中由 Active Directory 层次结构返回的 SearchResult 实例。
SelectedDatesCollection 封装 System.DateTime 对象的集合,这些对象表示 Calendar 控件中的选定日期。无法继承此类。
SignedInfo 包含有关用于 XML 签名的规范化算法和签名算法的信息。
SortedList 表示键/值对的集合,这些键和值按键排序并可按照键和索引访问。
SqlCeErrorCollection 收集 SQL Server CE .NET Framework 精简版数据提供程序产生的所有错误。无法继承此类。
SqlCeParameterCollection 收集与 SqlCeCommand 有关的所有参数以及它们各自到 DataSet 列的映射。
SqlErrorCollection 收集 SQL Server .NET Framework 数据提供程序生成的所有错误。无法继承此类。
SqlParameterCollection 表示与 SqlCommand 相关的参数集合以及这些参数各自到 DataSet 中的列的映射。无法继承此类。
Stack 表示对象的简单的后进先出集合。
StateBag 管理 ASP.NET 服务器控件(包括页)的视图状态。无法继承此类。
StatusBar.StatusBarPanelCollection 表示 StatusBar 控件中的面板集合。
StringCollection 表示字符串集合。
TabControl.TabPageCollection 包含 TabPage 对象集合。
TableCellCollection 封装 TableHeaderCellTableCell 对象的集合,这些对象组成了 Table 控件中的一行。无法继承此类。
TableRowCollection 封装 TableRow 对象的集合,这些对象表示 Table 控件中的单行。无法继承此类。
TempFileCollection 表示临时文件的集合。
ToolBar.ToolBarButtonCollection 封装一个 ToolBarButton 控件的集合,供 ToolBar 类使用。
TraceListenerCollection 提供 TraceListener 对象的线程安全列表。
TreeNodeCollection 表示 TreeNode 对象的集合。
TypeConverter.StandardValuesCollection 表示值的集合。
ValidatorCollection 公开一个 IValidator 引用数组。无法继承此类。
XmlAttributeCollection 表示可以按名称或索引访问的属性的集合。
XmlSchemaCollection 包含“XML 架构”定义语言 (XSD) 和“XML 数据缩减”(XDR) 架构的缓存。无法继承此类。

3,IEnumerable和IEnumerator
  IEnumerable提供一个方法公开枚举数,该枚举数支持在集合上进行简单迭代。
  IEnumerator支持在集合上进行简单迭代。通过IEnumerable我们可以获取到IEnumerator实例;因而实现迭代,注意,IEnumerator通过 MoveNext来实现迭代;
posted on 2008-01-17 17:00  Gabriel.Wang  阅读(576)  评论(0编辑  收藏  举报