
This doesn't provide direct answer, might have overview
IList provides you the flexibility of implement this functionality.
public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{
T this[int index] { get; set; }
int IndexOf(T item);
void Insert(int index, T item);
void RemoveAt(int index);
}
if you use class FootballTeam : List<FootballPlayer>
you can extent
the properties in your FootballTeam class.
Ideally it will be necessary when you want to extend your collection. Suppose you have to implement AddSort(T item) then class FootballTeam : List<FootballPlayer>
if you use class FootballTeam : ILIst<FootballPlayer>
you might be
reinventing the wheel that Add()
, and Contains()
should be
implemented by yourself
I would recommend to use Composition over inheritance
class FootballTeam : //So here can use any team base class or anything necessary
{
public string TeamName;
public int RunningTotal
private List<FootballPlayer> _players
public IEnumerable<FootballPlayer> Players {get;set;}
}
Update
I have updated the Players
as IEnumerable so will have much flexibility.
illustration and Credits from this link:
When To Use IEnumerable, ICollection, IList And List