I have a general list of entries. these records contain a dynamic array, for example, the following
Type
TMyRec=record
MyArr:Array of Integer;
Name: string;
Completed: Boolean;
end;
var
MyList:TList<TMyRec>;
MyRec:TMyRec;
then I create a list and set the length of the array as shown below.
MyList:=TList<TMyRec>.Create;
SetLength(MyRec.MyArr,5);
MyRec.MyArr[0]:=8; // just for demonstration
MyRec.Name:='Record 1';
MyRec.Completed:=true;
MyList.Add(MyRec);
then I change the data in MyArrand also change MyRec.Nameand add another item to the list
MyRec.MyArr[0]:=5;
MyRec.Name:='Record 2';
MyRec.Completed:=false;
MyList.Add(MyRec);
when MyRec.MyArrchanges after adding the first item to the list MyArr, which is saved in the list also changes. however, other record fields do not work.
My question is how to prevent changes from changing in MyRec.MyArran array that is already stored in the list item.
I need to declare several entries.