Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.


YOU ARE HERE: HOME Questions What are indexers in C NET What is the difference between property indexers In which case we use

Indexers in C# .NET

View(s): 16935

What are indexers in C# .NET? What is the difference between property & indexers? In which case we use indexers?

Answer 1)
C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C# community. Indexers permit instances of a class or struct to be indexed in the same way as arrays. Indexers are similar to properties except that their accessors (get/set) take parameters.

Indexers are most frequently implemented in types whose primary purpose is to encapsulate an internal collection or array. And also, as C# does not support parameterized properties, sometimes we implement indexers as alternatives.

To declare an indexer on a class or struct, use the this keyword, as in this example:

public int this[int index]    // Indexer declaration
    // get and set accessors
  Asked in:  SemanticSpace Technologies   Expertise Level:  Intermediate
  Last updated on Sunday, 07 August 2011
3/5 stars (11 vote(s))

Register Login Ask Us Write to Us Help