C#中索引器和数组的使用类似
public class Test
{
private readonly string[] name = new string[10];
public string this[int index]
{
get
{
return name[index];
}
set
{
name[index] = value;
}
}
}
static void Main(string[] args)
{
Test t = new Test();
t[1] = "张三";
Console.WriteLine(t[1]);
}
索引器能对数组进行过滤等操作