Use of namespaces

P

Paolo

I have a DLL of utility functions as:

using System;
using System.Linq;
using System.Text;

namespace Utilities
{
class myUtils
{

<various utility methods>

}
}


I have another DLL which makes use of the Utilities. When creating this
second DLL, is it sufficient to code 'using Utilities' or do I also have to
include the

using System;
using System.Linq;
using System.Text;

directives as well?

Thanks
 
J

Jon Skeet [C# MVP]

Paolo said:
I have a DLL of utility functions as:

using System;
using System.Linq;
using System.Text;

namespace Utilities
{
class myUtils
{

<various utility methods>

}
}


I have another DLL which makes use of the Utilities. When creating this
second DLL, is it sufficient to code 'using Utilities' or do I also have to
include the

using System;
using System.Linq;
using System.Text;

directives as well?

Just "using Utilities". The using directive is relevant to text within
that file.
 
P

Peter Rilling

You don't need to include namespaces used by your referenced assemblies,
only your own. That is unless you second DLL also needs to use some classes
within those namespaces.
 
A

Arne Vajhøj

Paolo said:
I have a DLL of utility functions as:

using System;
using System.Linq;
using System.Text;

namespace Utilities
{
class myUtils
{

<various utility methods>

}
}

I have another DLL which makes use of the Utilities. When creating this
second DLL, is it sufficient to code 'using Utilities' or do I also have to
include the

using System;
using System.Linq;
using System.Text;

directives as well?

You need:

using Utilities;

if you want to write:

myUtils.Foobar();

instead of:

Utilities.myUtils.Foobar();

You need:

using System.

if you want to use something from that namespace without
having to use the prefix.

I guess that was a long way of writing: no.

:)

Also:
- your class should be MyClass not myClass
- based on the context I think you want to make
myClass/MyClass public

Arne
 
P

Paolo

Peter: thanks.

Peter Rilling said:
You don't need to include namespaces used by your referenced assemblies,
only your own. That is unless you second DLL also needs to use some classes
within those namespaces.
 

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

Top