Monday, July 16, 2007

Property vs Indexer

Property

  • Identified by its name.
  • Accessed through a simple name or a member access.
  • 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.

Indexer

  • Identified by its signature.
  • Accessed through an element access.
  • 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: