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ə167/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   163   164   165   166   167   168   169   170   ...   294
DelphiLanguageGuide

Class Static Methods (.NET)
Like class fields and class properties, class static methods can be accessed without an object reference. Unlike
Win32 Delphi class methods, class static methods have no Self parameter at all, and therefore cannot access any
class members. Also unlike Win32 Delphi, class static methods cannot be declared virtual.
Methods are made class static by appending the word static to their declaration, for example
144


type
   TMyClass = class
     strict private
       class var
       FX: Integer;
         
     strict protected
    
       // Note: accessors for class properties must be declared class static.
       class function GetX: Integer; static;
       class procedure SetX(val: Integer); static;
     public
       class property X: Integer read GetX write SetX;
       class procedure StatProc(s: String); static;
   end;
You can call a class static method through the class type (i.e. without having an object reference), for example
TMyClass.X := 17;
TMyClass.StatProc('Hello');

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   163   164   165   166   167   168   169   170   ...   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