O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

Indexers Are Also Inherited and Can Be Overridden

Even though Chapter 14, “Class Anatomy III: Writing Intuitive Code,” told us that indexers do not carry a name, like its method and property siblings, but instead are called by referring to an object name followed by a pair of square brackets enclosing an indexer, they are still inherited and can be overridden like methods and properties. Listing 16.5 demonstrates how an indexer can be overridden and also introduces a new use for the base keyword (other than when used as part of the constructor initializer discussed earlier), which allows you to call the indexer of a base class.

Listing 16.5. SeasonalAdjustment.cs
 01: using System; 02: 03: class ProductionList 04: { 05: private uint[] production ...

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