Pages

Men

rh

6/16/2012

Difference between Properties and Indexers:

Difference between Properties and Indexers:
Property:
  • Allows methods to be called as though they were public data members.
  • Accessed through a simple name.
  • Can be a static or an instance member.
  • A get accessor of a property has no parameters.
  • A set accessor of a property contains the implicit value parameter.
Indexers:
  • Allows methods on an object to be called as though the object is an array.         
  • Accessed through an index.
  • Must be an instance member.
  • A get accessor of an indexer has the same formal parameter list as the indexer.
  • A set accessor of an indexer has the same formal parameter list as the indexer, in addition to the value parameter.

No comments :

Post a Comment