Autor Beitrag
en!gma
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Mi 20.08.08 11:03 
hallo.
also ich möchte einen code von delphi nach c# portieren.
nur leider beginnt der code schon mit records.

ich lerne c# im moment noch und konnte trotz langer suche
bei google und hier nichts vernünftiges finden.

also kurz und knapp:

wie portiere ich am besten records von delphi nach c#?

ich nutze visual studio 2008 falls das irgendetwas zu bedeuten hat. ;)

mfg

en!gma
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 20.08.08 11:07 
Die Entsprechung zu einem Record dürfte ein Struct sein :-)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TMyRecord = record
    x : Integer;
    y : Integer;
  end;


wird zu
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
    public struct MyRecord
    {
        public int x;
        public int y;
    }


Beachte: Auch Structs können Methode und Properties haben:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
    public struct MyRecord
    {
        private int x;
        public int X
        {
            get { return x; }
            set { x = value; }
        }

        private int y;
        public int Y
        {
            get { return y; }
            set { y = value; }
        }
    }

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
en!gma Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 378

win xp
delphi 7.0
BeitragVerfasst: Mi 20.08.08 11:11 
oha doch so einfach.
ich hatte schon angst denn ich habe nur eine möglichkeit gefunden da wurde auch von delphi zu c# besprochen und es war einfach SOOOO viel code...
naja vielen dank endlich kann ich weitermachen/anfangen ;)