通常来说,C#中类的索引器通常只有一个,就是THIS,但也可以有无数个,只要你的参数列表不同就可以了
索引器和返回值无关
- class A
- {
- public List<string> items = new List<string>();
- public string this[int i]
- {
- get { return items[i]; }
- set { items.Insert(i, value); }
- }
- public int this[string i]
- {
- get { return int.Parse(items[int.Parse(i)]); }
- set { items.Insert(int.Parse(i), value.ToString()); }
- }