I'm using this code to get the element type of an array
{$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 fails with an access violation on this line
Writeln(TRttiArrayType(T).ElementType.Name);
How I can get the element type of an array using the RTTI?