I am trying to create a list of lists but am having trouble instantiating the list.
IList<IList<T>> allLists = List<List<T>>();
I am getting a compile error with this line.
You'll have to instantiate a List of IList<T>, not a List of List<T>.
The reason is that by implementing IList<IList<T>> you are saying "Here is a list of some kind in which you can get or insert anything that implements IList<T>". Only objects of type List<T> can be inserted into List<List<T>>, so it is not allowed.
IList<IList<T>> allLists = new List<IList<T>>();
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