为什么在Delphi (XE)中以下代码会产生错误?
我认为在Delphi中的泛型类型是被插入到泛型函数中的,因此只有在使用不具有Add(string)方法的类型时才会出错。
unit UTest;
interface
type
TTest = class
public
procedure Foo<T>(A: T);
end;
implementation
{ TTest }
procedure TTest.Foo<T>(A: T);
begin
A.Add('hej');
end;
end.
我认为在Delphi中的泛型类型是被插入到泛型函数中的,因此只有在使用不具有Add(string)方法的类型时才会出错。