簡體   English   中英

Delphi:類屬性的錯誤2008年不兼容的類型

[英]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 ParamTParam 因此, SetParam需要將Index接收到數組中,並將TParam放入數組中。 相反,您的setter提供了索引和兩個字符串,兩個都不是TParam

合適的二傳手是

procedure SetParam(Index: Byte; const Value: TParam);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM