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
Copyright © 2021 Jogjafile Inc.
Not directly, as
System::DynamicArraydoes 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 eachStringfrom the 2 arrays into the 3rd array (Stringis 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
TStringDynArrayarrays as you want, eg: