Namespaces

  • Thread starter Thread starter C# Learner
  • Start date Start date
C

C# Learner

Can a namespace be divided over two different files in different
assemblies? I want to create two different assemblies for a library,
with the same namespace being the top-level namespace for each.

i.e.:

// Assembly 1.

namespace MyLibrary
{
//...
}

// Assembly 2.

namespace MyLibrary
{
//...
}
 
Can a namespace be divided over two different files in different
assemblies? I want to create two different assemblies for a library,
with the same namespace being the top-level namespace for each.

Yes, although 'internal' objects wont be visible within the same namespace
in another assembly.

n!
 
C# Learner said:
Can a namespace be divided over two different files in different
assemblies? I want to create two different assemblies for a library,
with the same namespace being the top-level namespace for each.

i.e.:

// Assembly 1.

namespace MyLibrary
{
//...
}

// Assembly 2.

namespace MyLibrary
{
//...
}

Hi C# Learner,

Yes, namespaces are logical entities and don't tie you down to a physical
file.

Joe
 
<snip>

Wow, I can even add to the System namespace!

The more I learn about this language, the more I like it.
 
Yes, but a class must be inside one file and the class name must be unique
in the namespace.

Mark Johnson, Berlin Germany
(e-mail address removed)
 
Until the next version of C# where it's likely the 'partial' modifier will
be implemented, which allows you to split a class across files.
 
Back
Top