|
May 27, 2002 Using Qualified Names Tips: May 2002
Yehuda Shiran, Ph.D.
|
|
You are always on the safe side when using qualified names, especially when you import namespaces. Why be surprised later with a name collision and unexpected behavior of your code? The following example demonstrates the need for qualified names. There are three imported namespaces, defined as follows:
Let's declare a local class now:
Let's import the three databases from above:
And then let's print some class members:
Here is the output of the above code:
Notice that when the class location is ambiguous, you must use fully-qualified names. The class Head, for example, appears in USA, UK, USA.Florida, and locally, so the namespace must prefix this class. The class Localization, however, appears only in the UK namespace, so there is no need to use the fully-qualified variable names.To learn more about JScript .NET, go to Column 109, JScript .NET, Part III: Classes and Namespaces.
People who read this tip also read these tips: Look for similar tips by subject: |