Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   c# sruct mit string inhalt nach delphi (https://www.delphipraxis.net/209695-c-sruct-mit-string-inhalt-nach-delphi.html)

KodeZwerg 11. Jan 2022 11:27

c# sruct mit string inhalt nach delphi
 
ich zerbreche mir gerade den kopf wie man so etwas nach delphi bringt
Delphi-Quellcode:
static struct foobar foobar[]=
{
    {"string0",0},
    {"string11 ",11},
    };
mein erster versuch sah so aus (weil dort static steht nahm ich const) aber ist wohl falsch da es ein record sein müsste
Delphi-Quellcode:
const
  foobar : array[0..11] of String = (
    'string0', // 0
    '', // 1
    '', // 2
    '', // 3
    '', // 4
    '', // 5
    '', // 6
    '', // 7
    '', // 8
    '', // 9
    '', // 10
    'string11' //11
    );
und es als record umzuwandeln da scheitere ich an der zuweisung des string inhalts
Delphi-Quellcode:
type
  foobar = record
    foobar : record
      case integer of
         0: (string);
        11: (string);
    end;
  end;
Hat jemand einen Rat?

himitsu 11. Jan 2022 12:21

AW: c# sruct mit string inhalt nach delphi
 
CASE : das ist "alternativ", also das Eine ODER das Andere, aber niemals Beides.

Delphi-Referenz durchsuchenTDictionary<>

BerndS 11. Jan 2022 12:33

AW: c# sruct mit string inhalt nach delphi
 
Würde das helfen?
Delphi-Quellcode:
const
  cFooBar: array [0..11] of record
     Value: string;
     ValueOrd: Byte;
    end = (
     (Value : 'String0'; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : ''; ValueOrd:0),
     (Value : 'String11'; ValueOrd:11));

KodeZwerg 11. Jan 2022 13:02

AW: c# sruct mit string inhalt nach delphi
 
Zitat:

Zitat von BerndS (Beitrag 1500449)
Würde das helfen?

In der Tat!
Ich bin auch schon etwas weiter gekommen aber deines schaut besser aus

Delphi-Quellcode:
type
  TFooBar = record
    name: PChar;
    level: Integer;
  end;
const
  FooBar: array of TFooBar = (
    (name:'string0'; level:0),
    (name:'string11'; level:11)
  );


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:48 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