Hi,

The following code snippet doesnâ??t compile with,

helloworld.cs(25,39): error CS0246: The type or namespace name 'Library' could not be found (are you missing a using directive or an assembly reference?)

Why canâ??t the â??Libraryâ?? namespace be found when its location â??Company.Applicationâ?? has been referenced in the Tester class.

using System;

namespace Company.Application.Library
{
class Math
{
public static int Add(int a, int b)
{
return(a + b);
}
}
}

namespace Test
{
using Company.Application;

class Tester
{
static void Main()
{
int iResult = Library.Math.Add(2, 2);
Console.WriteLine(iResult);
}
}
}

Re: Newbie Namespace Question by Jon

Jon
Thu Jun 10 03:59:59 CDT 2004

Yaiz <Yaiz@discussions.microsoft.com> wrote:
> The following code snippet doesn?t compile with,
>
> helloworld.cs(25,39): error CS0246: The type or namespace name
> 'Library' could not be found (are you missing a using directive or an
> assembly reference?)
>
> Why can?t the ?Library? namespace be found when its location
> ?Company.Application? has been referenced in the Tester class.

Namespaces aren't hierarchical as far as the compiler (or framework) is
concerned.

See http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85570.aspx for
more information.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too