集合 Enumerable Enumerator yield

集合:

通过索引来访问成员,--引申到索引器 的使用

 for foreach循环遍历 --引申到 IEnumerable IEnumerator(会引申到yield)

常用的集合操作,add, insert ,remove...

 

 

索引器:

类比从数组Array中拿一个元素值。 int[] a=new int{10,11,12};  int item=a[1];  这里的[1] 就是索引。

理解下面的一段: 

public class MyColllection

{

 private t=new Hashtable();

public XType this[int index]

{

get{return t[index];}

}

 

调用时,

MyCollection c=new MyCollection();

XType=c[1]; 

 

refer: 《.net之美》

《c# 高级编程第8版》 

posted @ 2019-12-11 23:19  breezesit  阅读(132)  评论(0编辑  收藏  举报