Lecture overview -- Keyboard shortcut: 'u'  Previous page: Overview of the class <b><kbd>Collection<T></kbd></b> -- Keyboard shortcut: 'p'  Next page: Specialization of Collections -- 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 9 : 36
Object-oriented Programming in C#
Collection Classes
Sample use of class Collection<T>

 

/user/normark/oop-csharp-1/sources/c-sharp/collections/collection/basic/prog.csBasic operations on a Collection of characters. This program is explained

A C# 3.0 Program.

/user/normark/oop-csharp-1/sources/c-sharp/collections/collection/basic/outputOutput of the program with basic operations on a Collection of characters.


  • Lessons learned:

    • The indexer   lst[idx] = expr   mutates an existing element in the collection

      • The length of the collection is unchanged

    • The Insert operation splices a new element into the collection

      • Push subsequent elements towards the end of the collection

      • Makes the collection longer

    • The Remove and RemoveAt operations take elements out of the collections

      • Pull subsequent elements towards the beginning of the collection

      • Makes the collection shorter