使用Delphi如何检查对象的字段是否为TList?使用Delphi检查字段是否为TList
我tryed使用此
var
c : TRttiContext;
t : TRttiType;
f : TRttiField;
begin
c := TRttiContext.Create;
t := c.GetType(Self.ClassType);
for f in t.GetFields do begin
//check if the field is TList<T>
//check also the Generic type T
end;
end;
-1,所有具有“ToArray”方法的类都会被找到...... – whosrdaddy
这就是我在上一段中所说的;) –
不只是列出后代,而是任何带有“ToArray”的类。例如。一个TQueue,或者一个可能的TMyListWhichIsNotATList ... –