C#集合基础和运用.docVIP

  • 0
  • 0
  • 约1.7万字
  • 约 13页
  • 2017-06-15 发布于北京
  • 举报
C#集合基础与运用 1.集合接口与集合类型 (1)集合的命名空间 大多数集合类都可以在System.Collections和System.Collections.Generic名称空间中找到。泛型集合位于System.Collections.Generic名称空间中;专用于特定类型的集合类位于System.Collections.Specialized名称空间中;线程安全的集合位于System.Collections.Concurrent名称空间中。 (2)集合接口介绍 1、IEnumerable与IEnumerator接口 其实IEnumerable接口是非常的简单,只包含一个抽象的方法GetEnumerator(),它返回一个可用于循环访问集合的IEnumerator对象。 ??? public interface IEnumerable ??? { ??????? IEnumerator GetEnumerator(); } IEnumerator对象有什么呢?它是一个真正的集合访问器,没有它,就不能使用foreach语句遍历集合或数组,因为只有IEnumerator对象才能访问集合中的项。IEnumerator接口定义了:一个Current属性用来获取当前集合中的项;MoveNext方法将游标的内部位置向前移动;Reset方法将枚举数设置为其初始位置,该位置位于集合中第一个

文档评论(0)

1亿VIP精品文档

相关文档