answersLogoWhite

0

What are indexers in c sharp?

User Avatar

Anonymous

14y ago
Updated: 8/19/2019

An indexer is a special kind of Property at instance level.

For example:

public class MyBook {

public string this[string stringIndex]

{ get { return null; } set { // }}

public string this[int intIndex] {

{ get { return null; } set { // }}

}

}

MyBook has two indexers, one in the form of string, one in the form of int.

Example continue:

MyBook aBook = new MyBook();

Console.WriteLine(aBook["Whatever"], aBook[100]);

User Avatar

Wiki User

14y ago

What else can I help you with?