What does "this[0]" mean in C#? -


i going through library code , saw method like:

public collapsingrecordnodeitemlist list {     { return this[0] collapsingrecordnodeitemlist; } } 

the class contains method not list or iterable, this[0] mean?

look indexer in class.

c# lets define indexers allow sort of access.

here example official guide "samplecollection".

public t this[int i]     {                 {             // indexer simple, , returns or sets              // corresponding element internal array.              return arr[i];         }         set         {             arr[i] = value;         }     } 

here definition the official language specification:

an indexer member enables objects indexed in same way array. indexer declared property except name of member followed parameter list written between delimiters [ , ]. parameters available in accessor(s) of indexer. similar properties, indexers can read-write, read-only, , write-only, , accessor(s) of indexer can virtual.

one can find full , complete definition in section 10.9 indexers of specification.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -