I have a class which inherits from a list of list implementing an indexer
public class TwoDList<T>: List<List<T>>
{
public T this[int row, int column]
{
get;
set ;
}
}
on newing it and using it like this :
TwoDCollection<int> target = new TwoDCollection<int>();
var linearSequecValue = target[0, 2];
but i get a compile time error ” No overload for method ‘this’ takes 2 argument “
It works fine (assuming you provide the
getandsetbodies); is this:TwoDList<T>/TwoDCollection<T>?List<T>/IList<T>somewhere?I should also say: it is usually a bad idea to inherit from
List<T>to provide functionality; encapsulating it would be better.Working example: