Use of namespaces

  • Thread starter Thread starter Paolo
  • Start date Start date
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
 
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.
 
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.
 
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
 
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.
 
Back
Top