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?
Of course:
public abstract class ClassWithAbstractIndexer
{
public abstract int this[int index]
{
get;
set;
}
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With