Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy const array to dynamic array in Delphi

I have a fixed constant array

constAry1: array [1..10] of byte = (1,2,3,4,5,6,7,8,9,10);

and a dynamic array

dynAry1: array of byte;

What is the easiest way to copy the values from constAry1 to dynAry1?

Does it change if you have a const array of arrays (multidimensional)?

constArys: array [1..10] of array [1..10] of byte = . . . . .
like image 949
Jim McKeeth Avatar asked Jun 11 '09 17:06

Jim McKeeth


1 Answers

From Delphi XE7, the use of string-like operations with arrays is allowed. Then you can declare a constant of a dynamic array directly. For example:

const
  KEY: TBytes = [$97, $45, $3b, $3e, $c8, $14, $c9, $e1];
like image 118
vfbb Avatar answered Nov 15 '22 22:11

vfbb