I use this code to get the type of an array element
{$APPTYPE CONSOLE} uses Rtti, SysUtils; type TFooArray= array of TDateTime; Var T : TRttiType; begin try T:=TRttiContext.Create.GetType(TypeInfo(TFooArray)); Writeln(TRttiArrayType(T).ElementType.Name); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
but the application does not work with access violation in this line
Writeln(TRttiArrayType(T).ElementType.Name);
How can I get the element type of an array using RTTI?
source share