.

C Sharp Indexers Assignment Help

INDEXERS

  • It has meaning in its name itself
  • It helps in indexing an objects like an array
  • Create indexer to a className, where classNameworks like a virtual array
  • The object of the classNamecan be accessed like an array
  • For which array accessing operator [] to be used

C Sharp Indexers Assignment Help By Online Tutoring and Guided Sessions from assignmenthippo.com


Syntax of one dimensional indexer

{`

type_of_an_element this [ int index]

{

//accesser get

get

{

// indexer return value

}

// accessor set.

set {

// indexer set value

}

}

`}

Use of Indexers

  • Indexer declaration is like a property
  • To define an indexer get and set accessors
  • Indexer returns a specific value from an instance
  • Also it sets a specific value to an instance
  • It can divide the instance of an object into little parts and it performs its get and set tasks
  • It cannot be defined with a specific name
  • But it is possible by the ‘this’ keyword
  • It refers current object instance

Example

indexers image 1
.