Search code examples
c#c#-4.0collectionsinterfacecollectionbase

IList List in collection base class?


question is Regarding the collection base class that implements a weird property:

protected IList List { get; }

1) What is Ilist List in collection base class?? ...

2) It is not even initialized ... how can it be accessed then ...

3) When to use this list?


Solution

  • 1) IList is a interface, any class that is a implemetation of a IList can be returned by the List property of your class. In other words, you only know it can do the interface specification of IList.

    2) You can't, you have to initialize your class before you can get the property List from the class. The IList is initialized as a class which implements the IList interface.

    3) That depends of the specification of the class. I would guess it returns the items in the current list as a IList.