A
Aniket Sule
Hi,
I am trying to use a class from one namespace in another via the using
directive. The 2 namespaces have some part of the name in common (A.B.x,
A.B.y). However in the second namespace, I am unable to access the class
from the first without qualifying it, which is what i want to avoid. Any
ideas what I am doing wrong?
I am attaching the code and compiler error below to show exactly what I am
trying to do,
Any help is greatly appreciated,
Thanks
Aniket
file1.cs -
using System;
namespace apstry.A.apstry1
{
public class apstry1
{
public apstry1()
{
}
public static void Dummy()
{
System.Windows.Forms.MessageBox.Show("dummy call");
}
}
public class noName
{
public noName()
{
}
}
}
file2.cs -
using System;
using apstry.A.apstry1;
namespace apstry.A.apstry2
{
public class Class11
{
public Class11()
{
System.Windows.Forms.MessageBox.Show("duh");
apstry1.apstry1.Dummy(); // -- this works
apstry1.Dummy();
/*--gives the error C:\temp\apstry2\apstry2\Class1.cs(22): The type or
namespace name 'Dummy' does not exist in the class or namespace
'apstry.A.apstry1' (are you missing an assembly reference?)*/
noName y;
noName z;
}
public void duh()
{
}
}
}
I am trying to use a class from one namespace in another via the using
directive. The 2 namespaces have some part of the name in common (A.B.x,
A.B.y). However in the second namespace, I am unable to access the class
from the first without qualifying it, which is what i want to avoid. Any
ideas what I am doing wrong?
I am attaching the code and compiler error below to show exactly what I am
trying to do,
Any help is greatly appreciated,
Thanks
Aniket
file1.cs -
using System;
namespace apstry.A.apstry1
{
public class apstry1
{
public apstry1()
{
}
public static void Dummy()
{
System.Windows.Forms.MessageBox.Show("dummy call");
}
}
public class noName
{
public noName()
{
}
}
}
file2.cs -
using System;
using apstry.A.apstry1;
namespace apstry.A.apstry2
{
public class Class11
{
public Class11()
{
System.Windows.Forms.MessageBox.Show("duh");
apstry1.apstry1.Dummy(); // -- this works
apstry1.Dummy();
/*--gives the error C:\temp\apstry2\apstry2\Class1.cs(22): The type or
namespace name 'Dummy' does not exist in the class or namespace
'apstry.A.apstry1' (are you missing an assembly reference?)*/
noName y;
noName z;
}
public void duh()
{
}
}
}