C# what is the point or benefit of an indexer?

后端 未结 11 2123
暖寄归人
暖寄归人 2020-12-16 16:07

Doing some code reading and stumbled upon this snippet that I haven\'t seen before:

public SomeClass {
  public someInterface this[String strParameter] {
            


        
11条回答
  •  孤街浪徒
    2020-12-16 16:40

    It allows you to do associative array lookups (a.k.a. "dictionary style"), just as you mentioned in your question.

    And that's the whole point. Some people like that, particularly people coming from languages that have it built in, like Python or PHP

提交回复
热议问题