在C#中,我们对集合的数据,可以创建一个索引器的方法来访问集合。如:
class AS { public string[] Autos = { "德系","欧系","美系","日系","韩系"}; public string this[int index] { get { return Autos[index]; } } }
测试索引器代码: