when to use Collection vs List [duplicate]

  • Collection<T>:

    Provides the base class for a generic
    collection.

  • List<T>:

    Represents a strongly typed list of
    objects that can be accessed by index.
    Provides methods to search, sort, and
    manipulate lists.

So, according the docs, one is intended as a base class for collections. The other is intended for use as a container.

So use List<T> and inherit from Collection<T>.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)