Alex Rivera | Logout

Any possibility to declare indexers in C# as an abstract member?

Asked 2011-10-02T11:59:33.283
13

As the title states, I would like to declare an indexer object this[int index] in an abstract class as an abstract member.

Is this possible in any way? Is it possible to declare this in an interface too?

Edit
Report

1 Answer

2

A simple example:

public interface ITest
{
    int this[int index] { get;  }
}

public class Test : ITest
{
    public int this[int index]
    {
        get { ... }
        private set { .... }
    }
}

Several combinations of private/protected/abstract are possible for get and set

answered 2011-10-02T12:20:43.113

Your Answer