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 X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...