spacer
Yehuda Shiran May 23, 2002
Using Qualified Class Names
Tips: May 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

When you import several namespaces in your code, and you reference a class member (a property or method), there is always the question from which namespace this class is referenced. The compiler first searches the local scope. If it doesn't find the class, the compiler searches the classes in each of the imported namespaces, in the order they were imported, and stops when it finds a match.

You can control the namespace you want to reference by using a fully qualified name. Here is an example:

  import System.Collections;
  var my_queue : System.Collections.Queue;
Assuming several namespaces include different types of the Queue class, you can use the fully-qualified name to force usage of an explicit namespace, the System.Collections namespace. But if you know that the class Queue is defined only once in all imported namespaces, you can use a shorter non-qualified name:

  import System.Collections;
  var my_queue : Queue;
You can mix fully-qualified and non-qualified class names. The advantage of fully-qualified names is that the code is much easier to debug because you know exactly where the classes reside.

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:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint