O'Reilly logo

Microsoft Visual C# 2013 Step by Step by John Sharp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16. Using indexers

After completing this chapter, you will be able to:

  • What is an indexer?

  • Control read access to indexers by declaring get accessors.

  • Control write access to indexers by declaring set accessors.

  • Indexers in interfaces

  • Implement indexers in structures and classes that inherit from interfaces.

Chapter 15 describes how to implement and use properties as a means of providing controlled access to the fields in a class. Properties are useful for mirroring fields that contain a single value. However, indexers are invaluable if you want to provide access to items that contain multiple values by using a natural and familiar syntax.

What is an indexer?

You can think of an indexer as a smart array in much the same way that you can think ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required