May 23, 2002 - Using Qualified Class Names
May 23, 2002 Using Qualified Class Names Tips: May 2002
Yehuda Shiran, Ph.D.
|
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.