游子日月长

笑渐不闻声渐悄,多情却被无情恼!

导航

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;

posted on 2017-01-10 16:53  游子日月长  阅读(268)  评论(0编辑  收藏  举报