更新:2007 年 11 月
错误消息
索引器不能有 void 类型
索引器的返回类型不能是 void。索引器必须返回某个值。
下面的示例生成 CS0620:
// CS0620.cs
class MyClass
{
public static void Main()
{
MyClass test = new MyClass();
System.Console.WriteLine(test[2]);
}
void this [int intI] // CS0620, return type cannot be void
{
get
{
// will need to return some value
}
}
}