GlobalĀ
Allows you to access a .NET Framework programming element when you have blocked it with your namespace structure.
Remarks
If you have defined a nested hierarchy of namespaces, code inside that hierarchy might be blocked from accessing the System namespace of the .NET Framework. The following example illustrates a hierarchy in which the SpecialSpace.System
namespace blocks access to System.
Namespace SpecialSpace
Namespace System
Class abc
Function getValue() As System.Int32
Dim n As System.Int32
Return n
End Function
End Class
End Namespace
End Namespace
As a result, the Visual Basic compiler cannot successfully resolve the reference to System.Int32, because SpecialSpace.System
does not define Int32
. You can use the Global keyword to start the qualification chain at the outermost level of the .NET Framework class library. This allows you to specify the System namespace or any other namespace in the class library. The following example illustrates this.
Namespace SpecialSpace
Namespace System
Class abc
Function getValue() As Global.System.Int32
Dim n As Global.System.Int32
Return n
End Function
End Class
End Namespace
End Namespace
You can use Global to access other root-level namespaces, such as Microsoft.VisualBasic, and any namespace associated with your project.
The Global keyword can be used in these contexts:
Class Statement (Visual Basic)
Const Statement (Visual Basic)
For...Next Statement (Visual Basic)
For Each...Next Statement (Visual Basic)
Function Statement (Visual Basic)
Interface Statement (Visual Basic)
Try...Catch...Finally Statement (Visual Basic)
Using Statement (Visual Basic)
See Also
Reference
Namespace Statement
.NET Framework Class Library Reference
System
Microsoft.VisualBasic