C# code, by default, is contained in the global namespace. This means that items contained in this code are accessible from other code in the global namespace simply by referring to them by name.
A qualified name is one that contains all of its hierarchical information, which basically means that if you have code in one namespaces that needs to use a name defined in a differnet namespace, you much include a reference to this namespace. Qualified names period characters(.) between namespace levels, as shown here:
namespace LevelOne
{
// code in LevelOne namespace
// name "NameOne" defined
}
// code in global namespace
{
// code in LevelOne namespace
namespace LevelTwo
{
// code in LevelOne.LevelTwo namespace
// name "NameTwo" defined
}
}
// code in global namespace
After namespaces are set up, you can use the using statement to simplify access to the names they contain. In effect, the using statement says, "OK, I'll be needing names fro this namespace, so don't bother asking me to classify them every time."
namespace LevelOne
{
using LT = LevelTwo;
// name "NameThree" defined
namespace LevelTwo
{
// name "NameThree" defined
}
}
A qualified name is one that contains all of its hierarchical information, which basically means that if you have code in one namespaces that needs to use a name defined in a differnet namespace, you much include a reference to this namespace. Qualified names period characters(.) between namespace levels, as shown here:
namespace LevelOne
{
// code in LevelOne namespace
// name "NameOne" defined
}
// code in global namespace
{
// code in LevelOne namespace
namespace LevelTwo
{
// code in LevelOne.LevelTwo namespace
// name "NameTwo" defined
}
}
// code in global namespace
After namespaces are set up, you can use the using statement to simplify access to the names they contain. In effect, the using statement says, "OK, I'll be needing names fro this namespace, so don't bother asking me to classify them every time."
namespace LevelOne
{
using LT = LevelTwo;
// name "NameThree" defined
namespace LevelTwo
{
// name "NameThree" defined
}
}
Comments
Post a Comment