C# Quick Question - Namespaces and : symbol

Started by
1 comment, last by TheUnbeliever 12 years ago
So I'm reading C# 4.0 in a Nutshell and I've hit another minor snag.

The book says

Name scoping
Names declared in outer namespaces can be used unqualified within inner namespaces.
Here, the names Middle and Class1 are implicitly imported into Inner:

namespace Outer
{
namespace Middle
{
class Class1 {}
namespace Inner
{
class Class2 : Class1 {}
}
}
}

If you want to refer to a type in a different branch of your namespace hierarchy, you
can use a partially qualified name. In the following example, we base SalesReport
on Common.ReportBase:
namespace MyTradingCompany
{
namespace Common
{
class ReportBase {}
}
namespace ManagementReporting
{
class SalesReport : Common.ReportBase {}
}
}
[/quote]

I'm not at all following what he's talking about even. Could someone explain this in a more beginner friendly manner?
Advertisement
: means implements or extends an interface or base class. It has nothing special to do with namespaces.

If A and B are under namespace N, B can use A. Otherwise, B must use N.A
He's really using lots of words to say that namespaces work as you'd expect - you can see things 'above' or 'across' from you, but not 'below' unless using the qualified (Common.ReportBase rather than just ReportBase) name.
[TheUnbeliever]

This topic is closed to new replies.

Advertisement