Jump to content
  • Advertisement
Sign in to follow this  
KorangarDev

C# Quick Question - Namespaces and : symbol

This topic is 2277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!