Indexers allow instances of a class or struct to be indexed just like arrays. Indexers resemble properties except that their accessors take parameters.


Creating indexer

The indexer can be created by pressing ‘plus’ button on Class Indexers section:

Note: If you can't find this section, check its visibility in the panel 'Hidden script objects' in the bottom of toolbar.


The indexer it’s like accessing to some element of array: it has the index of element (int type) and the value of element. You can get or set it.


The main properties of indexers:

  • Contains “get” and ‘set’ accessors (like a property);
  • Can have multiple parameters in accessor (at least one);
  • Don’t have a name;
  • The class can’t have few indexers with the same parameter types.


You can set indexer parameters and indexer type in Details window of indexer:

After compiling you will be able to use it in code:

Render time: 0.02 seconds
136,978 unique visits