public void SomeMethod() { PublicClass c = new PublicClass(); c.PublicMethod(); //Valid c.ProtectedMethod(); //Invalid, not accessible c.PrivateMethod(); //Also invalid }
static void MainX(string[] args) { var obj = new PublicClass(); Console.WriteLine(obj.PublicMethod()); //Console.WriteLine(obj.PrivateMethod()); //Console.WriteLine(obj.InternalMethod()); //var obj1 = new InternalClass(); }
private static void Main() { Console.WriteLine(new Inside.InternalInsideClass()); Console.WriteLine(new InternalClass()); var pub = new PublicClass(); Console.WriteLine(pub); pub.PublicMethod(); pub.InternalMethod(); //pub.ProtectedMethod(); //pub.PrivateMethod(); Console.WriteLine(new PublicClass.PublicNestedClass()); //Console.WriteLine(new PublicClass.ProtectedNestedClass()); //Console.WriteLine(new PublicClass.PrivateNestedClass()); Console.WriteLine(new SubClass()); var sub = new Sub("test"); Console.WriteLine(sub.Name); sub.BaseVirtualMethod(); Console.WriteLine(sub.Name); }