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
Post a Comment