Delphi Error – E2168 Field or method identifier expected

Delphi Compiler Error

E2168 Field or method identifier expected

Reason for the Error & Solution

You have specified an identifier for a read or write clause to a property which is not a field or method.

program Produce;

  var
    r : string;

  type
    Base = class
      t : string;
      property Title : string read Title write Title;
      property Caption : string read r write r;

    end;

begin
end.

The two properties in this code both cause errors. The first causes an error because it is not possible to specify the property itself as the read & write methods. The second causes an error because ‘r’ is not a member of the Base class.

program Solve;

  type
    Base = class
      t : string;
      property Title : string read t write t;
    end;

begin
end.

To solve this error, make sure that all read & write clauses for properties specify a valid field or method identifier that is a member of the class which owns the property.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...