Rajesh kumar’s Blog

If you have knowledge, let others light their candles at it.

  • Author

  • Rajesh Tweets

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • Enter your email address to follow this blog and receive notifications of new posts by email.

    Join 2 other followers

Difference between Property and Indexer in C#

Posted by Rajesh Kumar on April 16, 2009

Indexers are like properties. Except for the differences shown in the following table, all the rules that are defined for property accessors apply to indexer accessors also.

 

Actual Difference are:

Property

Indexer

Allows methods to be called as if they were public data members.

Allows elements of an internal collection of an object to be accessed by using array notation on the object itself.

Accessed through a simple name.

Accessed through an index.

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, and also to the value parameter.

Supports shortened syntax with Auto-Implemented Properties (C# Programming Guide).

Does not support shortened syntax.

Advertisements

13 Responses to “Difference between Property and Indexer in C#”

  1. AnnaHopn said

    Hi,
    Where are you from? Is it a secret? 🙂
    Thanks
    AnnaHopn

  2. vsyahalava said

    Всем, всем, всем Доброе утро! Заходите на всяхалява.рф – лучший сайт халявы.

  3. Frederick said

    powiadomił chrapliwym szeptem. – Również Frederick dziewice podobno, nie wiem, w
    jakim stopniu w
    tymże prawdziwości… Skromnie, pomyślał sir Roger,
    wieść gminna jakieś wyolbrzymia. W swej praktyce nie spotkał
    pod żadnym pozorem
    smoka, który.

  4. Reva said

    With havin so much content and articles do you ever run into any problems
    of plagorism or copyright violation? My blog has
    a lot of completely unique content I’ve either authored myself or outsourced but it appears a lot of it is popping it up all over the internet without my agreement. Do you know any ways to help reduce content from being stolen? I’d certainly appreciate it.

  5. Alexander said

    I used to be able to find good information from your
    blog posts.

  6. Rufus said

    Sewing outside chair cushions?

  7. Thanks for another informative site. Where else could I am getting that kind of info written in such an ideal
    approach? I’ve a undertaking that I am just now operating on, and I’ve been on the
    glance out for such info.

  8. Hmm it appears like your website ate my first comment (it was
    super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog writer but I’m still new to everything. Do you have any tips for newbie blog writers? I’d genuinely appreciate it.

  9. Good day! I could have sworn I’ve visited this website before but after looking at some of the articles I realized it’s
    new to me. Nonetheless, I’m certainly delighted I stumbled upon it and I’ll be bookmarking it and checking back
    regularly!

  10. Thank you, I have just been looking for information about
    this topic for a while and yours is the best I’ve found out till now.
    But, what concerning the conclusion? Are you certain in regards to the source?

  11. What’s Going down i’m new to this, I stumbled upon this I’ve found It positively helpful and it has helped me out loads.

    I’m hoping to give a contribution & help other users like its aided
    me. Great job.

  12. I am really grateful to the holder of this site who has shared this
    great post at at this time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: