I\'m doing the way I learned, that is: with a FOR and taking the Index array one by one, but it is leaving too slow, would otherwise convert it to a String? that leaves quicker?
I suspect that your code is slow because it is performing unnecessary reallocations of the string. However, without seeing your code it's hard to be sure.
Probably the simplest way to code your algorithm is to use TStringBuilder
. Whether or not that gives sufficient performance, only you can say.
sb := TStringBuilder.Create;
try
for i := 0 to high(buffer) do
begin
sb.Append(IntToStr(buffer[i]));
if i<high(buffer) then
sb.Append(',');
end;
str := sb.ToString;
finally
sb.Free;
end;