HomeCSharpC# Error CS0060 – Inconsistent accessibility: base class ‘class1’ is less accessible than class ‘class2’

C# Error CS0060 – Inconsistent accessibility: base class ‘class1’ is less accessible than class ‘class2’

C# Compiler Error

CS0060 – Inconsistent accessibility: base class ‘class1’ is less accessible than class ‘class2’

Reason for the Error

You would receive this error when you have a in-consistent access-modifiers between the child class (inherited) and the base class.

For example, try compiling the below code snippet.

class Employee
{
}

public class PartTimeEmployee : Employee
{

}

public class DeveloperPublish
{
    public static void Main() { 
    
    }
}

This will result with the compiler error because the Employee class is defined as private and is the base class for PartTimeEmployee.

C# Error CS0060 – Inconsistent accessibility: base class 'class1' is less accessible than class 'class2'

Error CS0060 Inconsistent accessibility: base class ‘Employee’ is less accessible than class ‘PartTimeEmployee’

Solution

Ensure that the type that you are using for the base class is public. You can set the access-modifier of the Employee class to public to fix this error.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...