Property using Array field



Setter/Getter with Array field
Smart pascal source code
type TTest = class FValues: array [0..12] of Integer; function GetValue(x: Integer): Integer; procedure SetValue(x, y: Integer); property Values[x: Integer]: Integer read GetValue write SetValue; default; end; function TTest.GetValue(x: Integer): Integer; begin Result := FValues[x]; end; procedure TTest.SetValue(x, y: Integer); begin FValues[x] := y; end; { unit1.pas } var x: Integer; t: TTest = TTest.Create; Begin for x := 0 to 10 do begin t[x] := x; WriteLn(t[x]); end; { CONSOLE OUTPUT 0 1 2 3 4 5 6 7 8 9 10 }