Lecture overview -- Keyboard shortcut: 'u'  Previous page: Example of associating Person with BankAccount -- Keyboard shortcut: 'p'  Next page: Methods [Section] -- 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 16 : 29
Object-oriented Programming in C#
Data Access, Properties, and Methods
Summary of indexers in C#

On this slides we mention a number of characteristics of indexers in C#.

 modifiers return-type this[formal-parameter-list]
  get {body-of-get}
  set {body-of-set}

The syntax of a C# indexer

  • Indexer characteristics

    • Provide for indexed read-only, write-only, or read-write access to data in objects

    • Indexers can only be instance members - not static

    • The indexing can be based on one, two or more formal parameters

    • Indexers can be overloaded

    • Indexers should be without unnecessary side-effects

    • Indexers should be fast