Name

Property Keyword

Syntax

property Name: Type read Getter write Setter;
property Name: Type read Getter write Setter
   index Constant default Constant stored Stored;
property Name[Index: IndexType]: BaseType read Getter write Setter;
    default;
property Name;

property Name: Type;             // in dispinterface declarations only
property Name: Type readonly;
property Name: Type writeonly;

property Name: Type read Getter implements Interfaces...;

Description

The property keyword begins a property declaration in a class, interface, or dispinterface declaration. A property can be invoked from an object or interface reference using the same syntax as a field, but you can use a method to implement access to the property. This gives you the best of both worlds: convenient syntax and flexible semantics, without sacrificing performance.

In a dispinterface declaration, a property can be declared as readonly or writeonly. The default (if both these directives are omitted) is read and write access.

A property can also provide the implementation of one or more interfaces. See the implements keyword for more information about this use of properties.

Tips and Tricks

  • Delphi lets you declare default and stored values for any property, but these directives are meaningful only for published properties. The compiler generates RTTI for the published property, including the values of the default and stored directives. These directives have no other impact on the language or the compiler, but the IDE reads the RTTI to ...

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.