Static and Instance Properties

When a property declaration includes the Shared modifier, this property is said to be a static property. When no Shared modifier is present, the property is said to be an instance property.

A static property does not operate on a specific instance, and it is a compile error to use the Self structure in static property accessors.

An instance property operates a given instance of a class, and that instance can be accessed using Self structure.

The differences between static and instance members are described further in the Static and Instance Members section.

Example

Class SharedProperty
    Shared s: string;
    o: object;
    //Static property
    Shared Public Property Version: string
        Get
        Begin
            Return s;
        End Get
        Set
        Begin
            s := Value;
        End Set
    End Property;
    //Instance property
    Public Property Object: object
        Get
        Begin
            Return o;
        End Get
        Set
        Begin
            o := Value;
        End Set
    End Property;
End Class;

Sub Test();
Var
    Obj: SharedProperty = New SharedProperty();
Begin
    SharedProperty.Version := "Class";
    Obj.Object := "Object";
End Sub;

See also:

Properties