M
Matt
Hi everyone,
can someone point out the difference between defining a class with the
public access modifier and just leaving it as it is (default in vs.net
"class")
I think that the default access modifier applied if one isn't defined;
so class would in fact be read as "private class" when it's compiled,
but that isn't the case.
When the code below code compiles, it will throw an error for c3, but
not for the other two classes. The fact that they're in different
namespaces also rules out that "class" is only visible within a
namespace.
I thought it might be only assembly-wide visible if defined without
the public access modifier, but, uh, I guess that's what the internal
keyword is for.
Thanks,
Matt
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var c1 = new n1.c1();
var c2 = new n2.c2();
var c3 = new n3.c3();
}
}
}
namespace n1
{
class c1
{
}
}
namespace n2
{
class c2
{
}
}
namespace n3
{
private class c3
{
}
}
can someone point out the difference between defining a class with the
public access modifier and just leaving it as it is (default in vs.net
"class")
I think that the default access modifier applied if one isn't defined;
so class would in fact be read as "private class" when it's compiled,
but that isn't the case.
When the code below code compiles, it will throw an error for c3, but
not for the other two classes. The fact that they're in different
namespaces also rules out that "class" is only visible within a
namespace.
I thought it might be only assembly-wide visible if defined without
the public access modifier, but, uh, I guess that's what the internal
keyword is for.
Thanks,
Matt
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var c1 = new n1.c1();
var c2 = new n2.c2();
var c3 = new n3.c3();
}
}
}
namespace n1
{
class c1
{
}
}
namespace n2
{
class c2
{
}
}
namespace n3
{
private class c3
{
}
}