小编Fab*_*ert的帖子

TObjectList <>获取项错误

我正在尝试在Delphi XE8中创建TObjectList类,但是当我尝试获取值时,我会收到错误.

编译器错误消息:"[dcc32错误]:无法访问私有符号{System.Generics.Collections} TList.GetItem"

这是我的代码:

unit Unit2;
interface
uses
  Classes, System.SysUtils, System.Types, REST.Types, System.JSON, Data.Bind.Components,
  System.RegularExpressions, System.Variants,
  Generics.Collections;

  type
  TTruc = class
  public
    libelle : string;
    constructor Create(pLibelle : string);
  end;

  TListeDeTrucs = class(TObjectList<TTruc>)
  private
    function GetItem(Index: Integer): TTruc;
    procedure SetItem(Index: Integer; const Value: TTruc);
  public
    function Add(AObject: TTruc): Integer;
    procedure Insert(Index: Integer; AObject: TTruc);
    procedure Delete(Index: Integer);
    property Items[Index: Integer]: TTruc read GetItem write SetItem; default;
  end;

implementation

{ TTruc }

constructor TTruc.Create(pLibelle: string);
begin
  libelle := pLibelle;
end; …
Run Code Online (Sandbox Code Playgroud)

delphi class tobjectlist delphi-xe8

6
推荐指数
1
解决办法
646
查看次数

标签 统计

class ×1

delphi ×1

delphi-xe8 ×1

tobjectlist ×1