Class-like records |
Top Previous Next |
New features since Delphi 7 > Class-like records Since Delphi 7 the abilities of records have been expanded to more class-like structures with properties, methods and nested types. Here an example from
http://docwiki.embarcadero.com/RADStudio/Rio/en/Structured_Types_(Delphi)#Records_.28advanced.29
type TMyRecord = record type TInnerColorType = Integer; var Red: Integer; class var Blue: Integer; procedure printRed(); constructor Create(val: Integer); property RedProperty: TInnerColorType read Red write Red; class property BlueProp: TInnerColorType read Blue write Blue; end;
implementation
constructor TMyRecord.Create(val: Integer); begin Red := val; end;
procedure TMyRecord.printRed; begin Writeln('Red: ', Red); end;
Delphi2C# converts these new features to:
public struct TMyRecord { public int Red; public static int Blue; public void printRed() { { Write("Red: "); WriteLn(Red); }; } public TMyRecord(int val) { Red = val; } public void Create(int val) { Red = val; } /*property RedProperty : TInnerColorType read Red write Red;*/ public int RedProperty { get { return Red; } set { Red = value; } } /*property BlueProp : TInnerColorType read Blue write Blue;*/ public static int BlueProp { get { return Blue; } set { Blue = value; } } public static TMyRecord CreateRecord(){return new TMyRecord();} };
|
This page belongs to the Delphi2C# Documentation |
Delphi2C# home Content |