我的类(class) MyClass 中有这段代码:
public new MyClass this[int index]
{
get
{
if (Count > index)
{
return this[index];
}
//...MyActions...
return null;
}
}
在字符串中...
return this[index]
...我有递归,但我需要使用 base 类中的属性。 不知道怎么弄的。
例子:
return base.this[index]
但我不能“覆盖”这个方法,只能设置"new"。我很伤心
怎么做? 对不起,我的英语很糟糕,谢谢
最佳答案
您可以使用 base关键字来访问基类的成员,包括索引器。尝试使用下一个代码片段在基类上调用索引器:
return base[index];
关于 'new'方法中的C#递归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14955939/