Skip to main content

Posts

Showing posts with the label indexer property in c#

Properties and Indexers in c#

Indexers  are a special type of array which is used to treat an object as array.  We say that indexer is a member which enables an object to be indexed just like array.  Indexers are permit to instances of a class or Structs to be indexed just like arrays.  Indexers are similar to properties .  Indexer is most useful for looping or iterating or data binding operations in c#. Syntax declaration of an indexer public int this [index] {   get {  }   set {  } } Modifier can be public, private, protected or internal. Just look like this.... public string Name {    get    {       return name;    }    set    {       name = value;    } } The modifier can be private, public, protected, internal. Indexers cannot be static because static methods do not have access to ...