Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions docs/csharp/misc/cs0060.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,40 @@
description: "Compiler Error CS0060"
title: "Compiler Error CS0060"
ms.date: 07/20/2015
f1_keywords:
f1_keywords:
- "CS0060"
helpviewer_keywords:
helpviewer_keywords:
- "CS0060"
ms.assetid: ae6d4fb7-5ff9-4883-82c3-f55b190f439a
---
# Compiler Error CS0060

Inconsistent accessibility: base class 'class1' is less accessible than class 'class2'

Class accessibility should be consistent between the base class and inherited class.

The following sample generates CS0060:

```csharp
// CS0060.cs
class MyClass
// try the following line instead
// public class MyClass
{
}

public class MyClass2 : MyClass // CS0060
{
public static void Main()
{
}
}
```

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`.

```csharp
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

- [Access Modifiers](../programming-guide/classes-and-structs/access-modifiers.md)