我使用Delphi 10.3。获取实例变量的相应TRTTIType
是一种例程。但是有什么方法可以填补这里标记为*缺少代码*的空白:
function getGenericTypeName<T> : string;
var
ctx : TRTTIContext;
aRT : TRTTIType;
begin
ctx := TRTTIContext.Create;
try
aRT := *** missing code for T *** // Get the TRTTIType for type T
result := aRT.Name;
finally
ctx.Free;
end;
end;
您正在寻找
ctx.GetType(TypeInfo(T))