A property declaration, which contains parameters is said to be an indexer. Declaration of an indexer permits it to be used in the same way as an array.
property-indexers:
[ property-indexer-list ]
property-indexer-list
property-indexer
property-indexer-list ; property-indexer
property-indexer:
identifier : type
Declaration of the property parameter is similar to method parameter declaration. The Out and Var modifiers cannot be used when determining property parameters.
It is a compile error for an indexer accessor to declare a local variable with the same name as an indexer parameter.
Parameterized properties overloading is permitted, that is, declaring several properties with the same name but different parameters signatures. In this case, the same rules are applied to names declaration as for overloaded method names declaration.
Class IndexProperty
i: array Of integer;
Constructor IndexProperty(Length: integer);
Begin
i := New integer[Length];
End Constructor;
Public Property Item[Index: integer]: integer
Get
Begin
Return i[Index];
End Get
Set
Begin
i[Index] := Value;
End Set
End Property;
End Class;
Sub Test();
Var
Obj: IndexProperty = New IndexProperty(1);
Begin
Obj.Item[0] := 100;
End Sub;
See also: