SyntaxGlobal[.namespace...]
DescriptionNew in 2005. The Global keyword provides a way to specify, without ambiguity, a namespace from the topmost level of the namespace hierarchy. Normally, specifying a full namespace is unambiguous. However, it is possible to create situations where conflicts arise. Consider the following code. Imports MyCompany Namespace MyCompany.System.Configuration Public Class Configuration ' ----- Class code here. End Class End Namespace Namespace MyCompany.MyProgram Public Module GeneralCode Public Sub SomeRoutine( ) ' ----- This next line is ambiguous. Dim whichOne As System.Configuration.Configuration End Sub End Module End Namespace The Dim statement in this code is ambiguous because there are now two System.Configuration namespaces: one at the top and one within the MyCompany namespace, both of which contain a Configuration class. To resolve this conflict, use the Global keyword to specify a full namespace from the very top of the hierarchy. Global appears just before all top-level namespaces. The two classes in this example can each be specified using the Global keyword as follows:
Version DifferencesThe Global keyword is new in Visual Basic 2005. See AlsoContinue Statement, On Error Statement |