Is there a way to concatenate the content of one TStringDynArray
to another TStringDynArray
?
//First TStringDynArray
Item1
Item2
Item3
//Second TStringDynArray
ItemA
ItemB
ItemC
//Result after concatenate
Item1
Item2
Item3
ItemA
ItemB
ItemC
Is there a way to concatenate the content of one TStringDynArray
to another TStringDynArray
?
//First TStringDynArray
Item1
Item2
Item3
//Second TStringDynArray
ItemA
ItemB
ItemC
//Result after concatenate
Item1
Item2
Item3
ItemA
ItemB
ItemC
Not directly, as
System::DynamicArray
does not provide concatenation features in C++. So you would need to create a 3rdTStringDynArray
, size it to the sum of the sizes of the 2 arrays, and individually copy eachString
from the 2 arrays into the 3rd array (String
is reference-counted, so you can't just copy bytes withmemcpy()
or equivalent, like you can with arrays of trivial types), eg:Alternatively (C++Builder 10.1 Berlin and later):
In the Clang-based compilers, you can take this a step further by using some variadic template functions to help you concatenate as many input
TStringDynArray
arrays as you want, eg: