Class Fields NET

Class fields are data fields in a class that can be accessed without an object reference.

You can introduce a block of class fields within a class declaration by using the class var block declaration. All fields 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:


TMyClass = class public class var // Introduce a block of class static fields.

Red: Integer; Green: Integer; Blue: Integer;

procedure Proci; // Ends the class var block.


The above class fields can be accessed with the code:

TMyClass.Red := 0; TMyClass.Green := 0; TMyClass.Blue := 0;

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