[英]Delphi: Error 2008 Incompatible types for a class property
我定义了这个班
TParamType = (ptDriverID, ptServer, ptHost, ptUser, ptPassword, ptPort, ptDatabase, ptOSAuth, ptPooled, ptUnicode);
TDataType = (dtInteger, dtString, dtBoolean, dtYesNo, dtPassword);
TParam = record
Index: Byte;
Typ: TParamType;
RegKeyName: String;
ConnName: String;
DataType: TDataType;
Caption: String;
Value: String;
Text: String;
Default: String;
Basic: Boolean;
Enabled: Boolean;
Mandatory: Boolean;
end;
TParams = class(TObject)
private
FParam: array of TParam;
function GetParam(Index:Byte): TParam;
procedure SetParam(Index:Byte;Value:String;Text:String);
public
constructor Create;
destructor Destroy;
property Param[Index: Byte]: TParam read GetParam write SetParam;
procedure Enable(ServerType:TServerType);
end;
我收到此错误:代码行出现“ E2008不兼容类型”
property Param[Index: Byte]: TParam read GetParam write SetParam;
知道为什么我会为此属性收到此错误吗?
property Param
是TParam
。 因此, SetParam
需要将Index
接收到数组中,并将TParam
放入数组中。 相反,您的setter提供了索引和两个字符串,两个都不是TParam
。
合适的二传手是
procedure SetParam(Index: Byte; const Value: TParam);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.