Delphi 动态数组合并

TIntArray = array of Integer;

function MergeArray(const ArrayA, ArrayB: TIntArray): TIntArray;

var

  ilen: Integer;

begin//Copy(intArray, iFromPos, Count) 选取拷贝,或者全部拷贝  Copy(intArray)

  Result := ArrayA;

  if Length(ArrayB) > 0 then begin

    ilen := Length(ArrayB) * sizeof(ArrayB[0]); //求数组内存长度,记住是内存长度

    SetLength(Result, Length(ArrayA) + Length(ArrayB));//设置数组长度

    CopyMemory(@Result[Length(ArrayA)], ArrayB, ilen); //把数组2复制到数组1后面,@Result[Length(valueA)]目标数组的追加起始位置

  end;

end;

原文地址:https://www.cnblogs.com/yzryc/p/6269998.html