Jeff,
Remember that private classes can only be declared INSIDE another
class. The private class member would only be accessible by the class
that it is inside, and in turn, the static public method as well. Here
is a quick example:
public class MainClass
{
public MainClass()
{
// you can call the static public method from here
MyPrivateClass.TestMethod();
}
// private classes can only be declared inside another class
private class MyPrivateClass
{
public MyPrivateClass()
{
// it works here as well of course
TestMethod();
}
public static void TestMethod()
{
}
}
}
public class AnotherClass
{
public AnotherClass()
{
// it doesn't work here, MyPrivateClass isn't accessible
MainClass.MyPrivateClass.TestMethod();
}
}
Hope that clears things up.
"z_learning_tester" <so*****@microsoft.com> wrote in message news:<RIPBc.88157$HG.75569@attbi_s53>...
Quick question-
What happens if you have a private class with a public static method?
Can you still say the following?
Lets say you are making this call from another class, say class2...
int myVal = class1.method();
It seems that you should not be able to, after all from class2, you should
not be able to see the private class1, so it's public static method is
effectively wasted.
Please correct me if I'm wrong.
Thanks,
Jeff