Delphi 泛型对象类

 {
很早就写了. 只针对delphixe 以上的版本可用.
  希望不是自己在造轮子. 
}
1
unit U_ClassUtility; 2 3 interface 4 uses generics.defaults,DateUtils,Classes,SysUtils,Windows, generics.collections; 5 6 type 7 TGenericList<T> = class 8 private 9 fList : Tlist<T>; 10 procedure SetList(const Value: TList<T>); 11 public 12 procedure clear; 13 procedure Add(Aobj : T); 14 15 constructor Create; 16 destructor Destroy; override; 17 property List : TList<T> read FList write SetList; 18 end; 19 20 implementation 21 { TGenericList<T> } 22 23 procedure TGenericList<T>.Add(Aobj: T); 24 begin 25 fList.Add(Aobj); 26 end; 27 28 procedure TGenericList<T>.clear; 29 var 30 i : Integer; 31 begin 32 for I := 0 to fList.Count -1 do 33 TObject(fList.Items[i]).Free; 34 35 fList.Clear; 36 end; 37 38 constructor TGenericList<T>.Create; 39 begin 40 fList := TList<T>.Create; 41 end; 42 43 destructor TGenericList<T>.Destroy; 44 begin 45 clear; 46 fList.Free; 47 inherited; 48 end; 49 50 procedure TGenericList<T>.SetList(const Value: TList<T>); 51 begin 52 FList := Value; 53 end; 54 55 end.

 

转载于:https://www.cnblogs.com/starluck/p/3643115.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值