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

后端 未结 11 2092
暖寄归人
暖寄归人 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:30

    The "this" keyword is an indexer

    from http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx

    "Indexers allow instances of a class or struct to be indexed just like arrays. Indexers resemble properties except that their accessors take parameters."

提交回复
热议问题