2

I would need an working example-program of an Explicit Interface Member Implementation of an Indexer.

Microsofts c# docu of Indexers states that this is possible, but does not provide a working example (at least for me the example is not working). I would need a working Program that does that.

Ini
  • 548
  • 7
  • 19
  • "for me the example is not working". What's not working? What errors do you get? It seems quite simple straight-forward code, so if it doesn't work, show what you have tried. – oerkelens Dec 10 '17 at 17:42

1 Answers1

2

The documentation seems to be wrong. I can’t check it now and I don’t recall ever implementing explicitly an indexer, but this should work:

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

class Foo: IInterface
{
    ReturnType IInterface.this[int index]
    {
        get { return ... }
    }
}
InBetween
  • 32,319
  • 3
  • 50
  • 90