Home  |  Contact us    
Indexers vs Properties in C#


What is the difference between indexers and properties in C#?

Comparison Between Properties and Indexers
Indexers are similar to properties. Except for the differences shown in the following , all of the rules defined for property accessors apply to indexer accessors as well.

PropertiesIndexers
Identified by its name. Identified by its signature.
Accessed through a simple name or a member access. Accessed through an element access.
Can be a static or an instance member. Must be an instance member.
A get accessor of a property has no parameters. A get accessor of an indexer has the same formal parameter list as the indexer.
A set accessor of a property contains the implicit value parameter. A set accessor of an indexer has the same formal parameter list as the indexer, in addition to the value parameter.





Category: OOPS Faqs Concepts Faqs, Interview Questions & Answers in C#



Ask New Questions
Microsoft.Net Framework
.Net 2.0 Namespaces
.Net Assemblies
OOPS Faqs in C#
ASP.Net Faqs
ASP.Net 2.0 Faqs
Web Services Faqs
ADO.Net Faqs
Database Faqs
OOPS Faqs
IT Project Management