Edit

Share via


Compiler Error CS0060

Inconsistent accessibility: base class 'Class1' is less accessible than class 'Class2'

In C#, a derived class cannot have broader accessibility than its base class. If the base class is less accessible, consumers of the derived class might unintentionally gain access to a class they shouldn't see.

Subclasses can never be more accessible than their base classes. That would allow consumers of the subclass broader access to the base type than was intended.

The following sample produces CS0060 because Class1 is internal and Class2 is public.

internal class Class1
{
}

public class Class2 : Class1 // 🛑 CS0060: Class1 is less accessible
{
}

You can resolve CS0060 in one of two ways:

  • Make the base class more accessible: Change Class1 to be public.
  • Restrict the derived class's accessibility: Change Class2 to be internal.

Tip

Base classes can be more accessible than their subclasses, but never less accessible.

See also