动态数组在声明时,只需要声明成员的类型,并不需要指定程序的序号,可在运行期间动态改变成员数量
http://www.cnblogs.com/del/archive/2009/11/11/1600876.html
//动态数组地址测试 var i: Integer; arr: TBytes; p: PByte; begin SetLength(arr, 5); for i := 0 to 4 do arr[i] := i + 65; ShowMessage(StringOf(arr)); {ABCDE} p := PByte(arr); ShowMessage(Chr(p^)); {A} p := PByte(@arr[2]); ShowMessage(Chr(p^)); {C} p^ := Ord('-'); ShowMessage(StringOf(arr)); {AB-DE} end; //合并两个动态数组: var arr1,arr2: TBytes; len: Integer; begin SetLength(arr1, 3); SetLength(arr2, 3); arr1[0] := 65; arr1[1] := 66; arr1[2] := 67; arr2[0] := 68; arr2[1] := 69; arr2[2] := 70; len := Length(arr1); SetLength(arr1, len + Length(arr2)); CopyMemory(@arr1[len], arr2, Length(arr2)); ShowMessage(StringOf(arr1)); {ABCDEF} end;