Utilities.Class1 as the
fully qualified name. The following example demonstrates an alternate way of defining nested
namespaces:
Namespace Acme
End Namespace
Namespace Acme.Utilities
Public Class Class1
End Class
End Namespace
The effect of this code is the exact same as the previous code. In fact, you may omit the
first empty namespace declaration for the Acme namespace. It??™s only left there to point out that
the Utilities namespace declaration is not physically nested within the Acme namespace declaration.
Any types that you declare outside of a namespace become part of the global
namespace.
Using Namespaces
Now let??™s take a look at how to use namespaces. We??™ll examine some code that uses the Class1
class that was defined in the previous section:
Dim c As Acme.Utilities.Class1 = New Acme.Utilities.Class1
Using the fully qualified name is rather verbose and might eventually lead to a bad case of
carpal tunnel syndrome. The Imports statement avoids this. The Imports statement creates a
sort of alias that tells the compiler that you??™re using an entire namespace or an individual class
in a namespace. In this case, Imports creates an implicit naming alias for the fully qualified
name. Most of the time, developers bring in the entire namespace, as in the following example:
Imports Acme.
Pages:
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79