RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2169: Field definition not allowed after methods or properties (Delphi)

You have attempted to add more fields to a class after the first method or property declaration has been encountered. You must place all field definitions before methods and properties.

program Produce;

  type
    Base = class
      procedure FirstMethod;
      a : Integer;
    end;


  procedure Base.FirstMethod;
  begin
  end;

begin
end.

The declaration of 'a' after 'FirstMethod' will cause an error.

program Solve;

  type
    Base = class
      a : Integer;
      procedure FirstMethod;
    end;


  procedure Base.FirstMethod;
  begin
  end;

begin
end.

To solve this error, it is normally sufficient to move all field definitions before the first field or property declaration.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!