Lecture overview -- Keyboard shortcut: 'u'  Previous page: The Interface <b><kbd>IList<T></kbd></b> -- Keyboard shortcut: 'p'  Next page: Sample use of class <b><kbd>Collection<T></kbd></b> -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 8 : 36
Object-oriented Programming in C#
Collection Classes
Overview of the class Collection<T>

The class Collection<T> offers a basic repertoire of list operations

Collection<T> holds the operations prescribed by IEnumerable<T>, ICollection<T>, and Ilist<T> - and not much more

The Collection<T> class is located in the namespace System.Collections.ObjectModel

 

  • Members of the class Collection<T>

    • Constructors

      • Collection(),   Collection(IList<T>)

      • Via a collection initializer: new Collection<T> {t1, t2, ..., tn}

    • Element access

      • this[int]

    • Measurement

      • Count

    • Element addition

      • Add(T),   Insert(int, T)

    • Element removal

      • Remove(T),   RemoveAt(int),   Clear()

    • Searching

      • IndexOf(T)

    • Boolean Queries

      • Contains(T)

    • Conversions

      • CopyTo(T[],int)