Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə180/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   176   177   178   179   180   181   182   183   ...   294
DelphiLanguageGuide

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



Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   176   177   178   179   180   181   182   183   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin