Adding to an existing NameSpace

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After creating a namespace in one file how would I add to that a new object
in the same namespace in a diffrent file?

IE
FILE1 contains namespace FINANCE
FILE2 has object that want to exist in the FINANCE namespace

Can this be done without adding the classes to FILE1?

Thanks
Davinci
 
Just declare the fully formed namespace in the new file such as:

namespace Foo.Bar.Re.Po
{
}


--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Davinci_Jeremie said:
After creating a namespace in one file how would I add to that a new object
in the same namespace in a diffrent file?

IE
FILE1 contains namespace FINANCE
FILE2 has object that want to exist in the FINANCE namespace

Can this be done without adding the classes to FILE1?

Just declare the namespace again. Note that you're not adding an
*object* to a namespace, you're adding a *type* to a namespace.
 
Yes.

Just declare the classes in FILE2 to be in the namespace you want them
in.

Projects using classes from that namespace will not know that the
namespace is in more than one DLL unless you refer to something defined
in that namespace but in a DLL that your project doesn't contain a
reference to. If you do this, the compiler will complain that it can't
find that class (or whatever) in that namespace, and maybe you're
missing a DLL reference?

If you write a project that only ever refers to things in FILE1, the
compiler doesn't know that there is "more" of the same namespace in
FILE2, and doesn't care.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top