索引器 - 显式接口成员实现

Indexer - Explicit Interface Member Implementation

我需要一个索引器的显式接口成员实现的工作示例程序。

Microsofts c# docu of Indexers 指出这是可能的,但没有提供一个有效的例子(至少对我来说这个例子不起作用)。我需要一个可以执行此操作的工作程序。

文档似乎有误。我现在无法检查它,我不记得曾经明确地实现过索引器,但这应该有效:

interface IInterface
{
    ReturnType this[int index] { get; }
}

class Foo: IInterface
{
    ReturnType IInterface.this[int index]
    {
        get { return ... }
    }
}