الإعلان عن متغير

[ STATIC ] { PUBLIC | PRIVATE } Identifier [ Static array declaration ] AS Datatype [ = Expression ]

This declares a class global المتغير.

Access

This المتغير is accessible everywhere in the class it is declared.

  • If the PUBLIC keyword is specified, it is also accessible to the other classes having a reference to an of this class.

  • If the STATIC keyword is specified, the same variable will be shared with every of this class.

Examples

STATIC PUBLIC GridX AS Integer
STATIC PRIVATE bGrid AS Boolean
PUBLIC Name AS String
PRIVATE Control AS Object

Initialization

The المتغير can be initialized with any Expression.

Examples

PRIVATE Languages AS String[] = [ "fr", "it", "es", "de", "ja" ]
PRIVATE DefaultLanguage AS String = Languages[1]

Alternatively, you can initialize the variable with a newly instanciated .

[ STATIC ] { PUBLIC | PRIVATE } Identifier AS NEW Class ( Arguments ... )

Examples

STATIC PRIVATE Tasks AS NEW List
PRIVATE MyCollection AS NEW Collection(gb.Text)

Or you can initialize the variable with a native .

[ STATIC ] { PUBLIC | PRIVATE } Identifier AS NEW Native Datatype [ Array dimensions ... ]

Note that you can use any expression for specifying array dimensions.

Examples

PUBLIC CONST WORD_MAX AS Integer = 12
PRIVATE Words AS NEW String[WORD_MAX * 2]
PUBLIC Matrix AS NEW Float[3, 3]

إنظر أيضا