DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: jsuguo
今日帖子: 31
在线用户: 17
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 hedgewirter (穷书生) ★☆☆☆☆ -
盒子活跃会员
2019/1/9 11:08:14
标题:
请教一个array of TObjectList<TFileInfo>的问题 浏览:700
加入我的收藏
楼主: unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Generics.Collections, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type
  TFileInfo = class
private
  FFilePath: string;
public
  property FilePath: string read FFilePath write FFilePath;

  end;
var
  Form1: TForm1;
  i:Integer;
  FileInfo:TFileInfo;
  FileInfo_List: TObjectList<TFileInfo>;
  FileInfo_List_Array:array of TObjectList<TFileInfo>;
  arry:array of Integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  FileInfo.FilePath := 'C';
  FileInfo_List.Add(FileInfo);
  FileInfo_List_Array[0] := FileInfo_List;
  FileInfo_List.Clear;
  FileInfo_List := FileInfo_List_Array[0];  //请问一下为什么到这儿 FileInfo_List 没有数据了
  for i := 0 to FileInfo_List.Count - 1 do
  begin
    ShowMessage(FileInfo_List[i].FilePath);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
FileInfo := TFileInfo.Create;
FileInfo_List:= TObjectList<TFileInfo>.Create;
SetLength(FileInfo_List_Array,4);
end;

end.
----------------------------------------------
-
作者:
男 hs_kill (lzl_17948876) ★☆☆☆☆ -
普通会员
2019/1/9 11:40:15
1楼: 你前面不是clear了么....当然没数据了啊
----------------------------------------------
http://www.cnblogs.com/lzl_17948876/
作者:
男 hedgewirter (穷书生) ★☆☆☆☆ -
盒子活跃会员
2019/1/9 13:36:59
2楼:   FileInfo_List_Array[0] := FileInfo_List;
  FileInfo_List.Clear;
  FileInfo_List := FileInfo_List_Array[0];//为什么这儿不能从 FileInfo_List_Array[0]中取值呢
==========
procedure TForm1.Button2Click(Sender: TObject);
var
  arry:array of Integer;
  n:Integer;
begin
SetLength(arry,4);
n :=10;
arry[0] :=n;
n := 0;
n := arry[0];      //n=10 为什么这儿这个N又能从aryy中取值呢

end;
----------------------------------------------
-
作者:
男 ptdelphi (Delphi) ▲▲▲▲△ -
普通会员
2019/1/9 19:05:37
3楼: 你不又赋值了吗
----------------------------------------------
还可以更好
作者:
男 sail2000 (小帆工作室) ★☆☆☆☆ -
盒子活跃会员
2019/1/9 19:51:58
4楼: 我噗。。。
----------------------------------------------
delphi 是兴趣,和工作无关,即使它倒闭。又不靠它 delphi 吃饭,怕甚?
作者:
男 janker (janker) ★☆☆☆☆ -
盒子活跃会员
2019/1/9 21:18:51
5楼: FileInfo_List_Array[0] := FileInfo_List;
这一句只是引用,没有复制,FileInfo_List_Array[0]只是指向了FileInfo_List,
FileInfo_List.Clear了,FileInfo_List_Array[0]当然也没了
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行179.6875毫秒 RSS