using System;
public class MyClassContainer
{
private MyClass MyClass_Instance;
public void DemonstrateAccessLevels()
{
MyClass_Instance = new MyClass();
MyClass_Instance.SomePublicMethod();
MyClass_Instance.SomeInternalMethod();
// we can't access protected or private methods of MyClass from MyClassContainer
//
//error CS0122: `MyClass.SomeProtectedMethod()' is inaccessible due to its protection level
//MyClass_Instance.SomeProtectedMethod();
//error CS0122: `MyClass.SomePrivateMethod()' is inaccessible due to its protection level
//MyClass_Instance.SomePrivateMethod();
}
}
public class MyClass
{
private void SomePrivateMethod()
{
Console.WriteLine("Some Private Method");
}
protected void SomeProtectedMethod()
{
Console.WriteLine("Some Protected Method");
}
internal void SomeInternalMethod()
{
Console.WriteLine("Some Internal Method");
}
public void SomePublicMethod()
{
Console.WriteLine("Some Public Method");
}
}
public class Test
{
public static void Main()
{
MyClassContainer testContainer = new MyClassContainer();
testContainer.DemonstrateAccessLevels();
}
}