Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   array of String "verketten" (https://www.delphipraxis.net/185872-array-string-verketten.html)

hoika 14. Jul 2015 10:12

array of String "verketten"
 
Hallo,

folgendes geht nicht

Delphi-Quellcode:
var
  a: array of String;
begin
  a := ['a','b'];
  a := a+['c'];
end;
Gibt es da einen Trick ohne mit SetLength zu arbeiten?

Danke


Heiko

SProske 14. Jul 2015 10:25

AW: array of String "verketten"
 
Ab Delphi XE7 sollte das so funktionieren, davor entsprechend nicht.

http://blog.marcocantu.com/blog/2014...delphixe7.html

Union 14. Jul 2015 10:32

AW: array of String "verketten"
 
Welche Delphi-Version? Bei XE7/8 geht Folgendes:
Delphi-Quellcode:
program ArrConcat;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

var
  a : TArray<string>;
  s : string;
begin
  a := ['a', 'b'];
  a := a + ['c'];

  for s in a do
    writeln(s);

  readln;
end.
Ausgabe:
Code:
a
b
c


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:17 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz