I have the following code which I am having trouble with. The problem
is detailed in the comments near the end.
Constants.cs:
--------------
namespace MyApp.Const
{
public class Const
{
public const int iID = 26;
public const string sUser = "Joe";
........
}
}
Main.cs
---------
using namespace MyApp.Const;
namespace MyApp.Main
{
public class MyClass
{
.....
private void SomeFunction()
{
int i = Const.iID; // causes compiler error
'The type or namespace name 'iID' does not exist in the class or
namespace 'MyApp.Const' (are you missing an assembly reference?)'
int i = Const.Const.iID; // works, but why the
double Const?
}
}
}
How can I get around this problem? I have found that it works if I
change the namespace name in Constants.cs to something like
MyApp.Constants(ie: different to the name of the class inside it), but
I would prefer to have the names the same.
Thanks