In C# you cannot declare classes as protected, except when they are nested within other classes:
namespace test
{
public class A
{
public A()
{
}
protected class B // nested class
{
}
}
}
This makes sense because protected
means that it should only be accessible by the enclosing class or a class derived from that enclosing class.
If it is ok if class B can be accessed by all classes in the same assembly but not from outside, you can declare the class as internal
:
namespace test
{
public class A
{
public A()
{
}
}
internal class B // accessible within same assembly
{
}
}