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 type

TMyClass = class strict private class var FX: Integer;

strict protected

// Note: accessors for class properties must be declared class static. function GetX: Integer; static; procedure SetX(val: Integer); static;

public class property X: Integer read GetX write SetX; procedure StatProc(s: String); static;


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');

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment