Pages

Friday, November 21, 2008

Differences Between Properties and Indexers in C#

Properties:

1)Identified by its name.
2)Accessed through a simple name or a member access.
3)Can be a static or an instance member.
4)A get accessor of a property has no parameters.
5)A set accessor of a property contains the implicit value parameter.

Indexers:
1)Identified by its signature.
2)Accessed through an element access.
3)Must be an instance member.
4)A get accessor of an indexer has the same formal parameter list as the indexer.
5)A set accessor of an indexer has the same formal parameter list as the indexer, in addition to the value parameter.

No comments: