Name
Property Keyword
Syntax
propertyName:TypereadGetterwriteSetter; propertyName:TypereadGetterwriteSetterindexConstantdefaultConstantstoredStored; propertyName[Index:IndexType]:BaseTypereadGetterwriteSetter; default; propertyName; propertyName:Type; // in dispinterface declarations only propertyName:Typereadonly; propertyName:Typewriteonly; propertyName:TypereadGetterimplementsInterfaces...;
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
defaultandstoreddirectives. These directives have no other impact on the language or the compiler, but the IDE reads the RTTI to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access