Delphi Compiler Error
E2132 Default property must be an array property
Reason for the Error & Solution
The default property which you have specified for the class is not an array property. Default properties are required to be array properties.
program Produce;
type
Base = class
function GetVÂ : Char;
procedure SetV(x : Char);
property Data : Char read GetV write SetV; default;
end;
function Base.GetVÂ : Char;
begin GetVÂ := 'A';
end;
procedure Base.SetV(x : Char);
begin
end;
begin
end.
When specifying a default property, you must make sure that it conforms to the array property syntax. The ‘Data’ property in the above code specifies a ‘Char’ type rather than an array.
program Solve;
type
Base = class
function GetV(i : Integer) : Char;
procedure SetV(i : Integer; const x : Char);
property Data[i : Integer] : Char read GetV write SetV; default;
end;
function Base.GetV(i : Integer) : Char;
begin GetVÂ := 'A';
end;
procedure Base.SetV(i : Integer; const x : Char);
begin
end;
begin
end.
By changing the specification of the offending property to an array, or by removing the ‘default’ directive, you can remove this error.