USING (Namespaces)
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgUsing
- Last revised: 2021-12-26
Brings namespace symbols into the current scope
Syntax
` Using identifier [, identifier [, ...] ]
`
Parameters
identifier: The name of the Namespace that you want to use.
Description
The Using command allows all symbols from a given namespace to be accessed without the namespace's name prefix. Unlike C++ but like C#, the Namespace keyword is not needed after Using, because individual symbols cannot be inherited from a namespace.
Using is allowed in namespaces and procedures only (not in type or union or enum declarations).
Inheriting a whole namespace can save typing, but sometimes some meaning of the code can be lost, and conflicts with other symbols could be created.
Examples
start GeSHi
vb
Namespace Sample
Type T
x As Integer
End Type
End Namespace
'' Just using the name T would not find the symbol,
'' because it is inside a namespace.
Dim SomeVariable As Sample.T
'' Now the whole namespace has been inherited into
'' the global namespace.
Using Sample
'' This statement is valid now, since T exists
'' without the "Sample." prefix.
Dim OtherVariable As Tend GeSHi
Version
- Before fbc 1.09.0, if there is duplicated symbol in the global namespace (unnamed namespace), access to local symbol is captured by duplicated global symbol (in that case, full prefixing is required to access local symbol).
Differences from QB
- QB had the
Usingkeyword, but for other purposes. Namespaces did not exist in QB.
See also
Print Using? UsingPalette UsingNamespace
Back to DocToc