Nested classes |
Top Previous Next |
New features since Delphi 7 > Nested classes The possibility to work with nested classes is new since Delphi 7. Here an example from:
http://docwiki.embarcadero.com/RADStudio/Rio/en/Nested_Type_Declarations
type TOuterClass = class strict private myField: Integer;
public type TInnerClass = class public myInnerField: Integer; procedure innerProc; end;
procedure outerProc; end;
implementation
procedure TOuterClass.TInnerClass.innerProc; begin // ... end;
procedure foo; var x: TOuterClass; y: TOuterClass.TInnerClass;
begin x := TOuterClass.Create; x.outerProc; //... y := TOuterClass.TInnerClass.Create; y.innerProc; end;
Delphi2C# converts this to:
public class TOuterClass : TObject { private int myField;
public class TInnerClass : TObject { public int myInnerField; public void innerProc() {
// ... }
public TInnerClass() {} }; //# public void outerProc();
public TOuterClass() {} };
public class testClass {
public static void foo() { TOuterClass x = null; TOuterClass.TInnerClass y = null; x = new TOuterClass(); x.outerProc(); //... y = new TOuterClass.TInnerClass(); y.innerProc(); }
} // testClass
|
This page belongs to the Delphi2C# Documentation |
Delphi2C# home Content |