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ə44/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   40   41   42   43   44   45   46   47   ...   294
DelphiLanguageGuide

Qualified Identifiers
When you use an identifier that has been declared in more than one place, it is sometimes necessary to qualify the
identifier. The syntax for a qualified identifier is
identifier1.identifier2
where identifier1 qualifies identifier2. For example, if two units each declare a variable called 
CurrentValue
, you
can specify that you want to access the 
CurrentValue
 in 
Unit2
 by writing
Unit2.CurrentValue
Qualifiers can be iterated. For example,
Form1.Button1.Click
calls the 
Click
 method in 
Button1
 of 
Form1
.
26


If you don't qualify an identifier, its interpretation is determined by the rules of scope described in Blocks and scope.
Extended Identifiers
When programming with Delphi for .NET, you might encounter CLR identifiers (e.g. types, or methods in a class)
having the same name as a Delphi language keyword. For example, a class might have a method called 
begin
.
Another example is the CLR class called Type, in the System namespace. Type is a Delphi language keyword, and
cannot be used for an identifier name.
If you qualify the identifier with its full namespace specification, then there is no problem. For example, to use the
Type class, you must use its fully qualified name:
var
            TMyType : System.Type; // Using fully qualified namespace
                                   // avoides ambiguity with Delphi language keyword.
As a shorter alternative, Delphi for .NET introduces the ampersand (&) operator to resolve ambiguities between CLR
identifiers and Delphi language keywords. If you encounter a method or type that is the same name as a Delphi
keyword, you can omit the namespace specification if you prefix the identifier name with an ampersand. For example,
the following code uses the ampersand to disambiguate the CLR Type class from the Delphi keyword type
var
           TMyType : &Type; // Prefix with '&' is ok.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   40   41   42   43   44   45   46   47   ...   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