C# Multiple Indexers

后端 未结 7 1060
深忆病人
深忆病人 2020-12-30 05:10

Is it possible to have something like the following:

class C
{
    public Foo Foos[int i]
    {
        ...
    }

    public Bar Bars[int i]
    {
        .         


        
7条回答
  •  执念已碎
    2020-12-30 05:49

    No you cant do it. Only methods that can have their signatures differ only by return type are conversion operators. Indexers must have different input parameter types to get it to compile.

提交回复
热议问题