I want to create independent copies of DynamicArrays involving class (not Records). I am using Delphi XE5. In the example code below, after all the assignments are done, all cop
You can copy the array like so:
function CloneArray(original: TArray_Of_TX): TArray_Of_TX;
var
i: integer;
copy: TX;
begin
Result.SetLength(SizeOf(original));
for i:= 0 to SizeOf(original) -1 do begin
copy:= TX.Create;
copy.assign(original[i]);
Result[i]:= copy;
end; {for i}
end;
This version does not use generics, because I'm not sure how to create a generic version using a dynamic array.