把C#对象变成数组技术---索引器,indexer

 1 public class IndexerDemo
 2     {
 3         IList list = new List();
 4 
 5         public IndexerDemo()
 6         {
 7             list.Add("1");
 8             list.Add("2");
 9         }
10 
11         public string this[int i]
12         {
13             get
14             {
15                 return list[i];
16             }
17             set
18             {
19                 list[i] = value;
20             }
21         }
22 
23     }
24 
25 
26 //调用:
27             var id = new IndexerDemo();
28             var ids = id[1]; //这里,变数组了!