Class Properties (.NET) Class properties can be accessed without an object reference. Class property accessors must themselves be
declared as class static methods, or class fields. A class property cannot be published, and cannot have stored or
default value definitions.
You can introduce a block of class static properties within a class declaration by using the class var block declaration.
All properties declared after class var have static storage attributes. A class var block is terminated by the following:
1 Another class var declaration
2 A procedure or function (i.e. method) declaration (including class procedures and class functions)
3 A property declaration (including class properties)
4 A constructor or destructor declaration
5 A visibility scope specifier (public, private, protected, published, strict private, and strict protected)
For example:
type
TMyClass = class
strict private
class var // Note fields must be declared as class fields
FRed: Integer;
FGreen: Integer;
FBlue: Integer;
public
class var // Introduce a block of class properties
property Red: Integer read FRed write FRed;
Green: Integer read FGreen write FGreen;
Blue: Integer read FBlue write FBlue;
procedure Proc1; // Ends the class var block.
end;
You can access the above class properites with the code:
TMyClass.Red := 0;
TMyClass.Blue := 0;
TMyClass.Green := 0;
156