Is there way of copying the whole array into another array? (Other than using a For-loop)

前端 未结 6 1343
孤街浪徒
孤街浪徒 2020-12-14 23:40

Is there way of copying the whole array into another array? Other than using a for-loop.

Does the move or copy command work for this? I did try but it had an error:

6条回答
  •  攒了一身酷
    2020-12-14 23:48

    For dynamic arrays:

    var A,B: array of Byte;
    
    begin
      SetLength(A, );
      //initialize A
    
      B:= A; 
      SetLength(B,Length(A));
    
    end;
    

    In dynamic arrays, the assignment statement duplicates only the reference to the array, while SetLength does the job of physically copying/duplicating it, leaving two separate, independent dynamic arrays.

提交回复
热议问题