There are two classes; when inheriting, the compiler displays the error "Inconsistent accessibility base class is less accessible than class."

public abstract class WaresTreeDataModel { public abstract void SomeMethod(); } public sealed class OraWaresTreeDataModel : WaresDataModel { public override void SomeMethod() { } } 

What is wrong here? Version .net Framework 4.5.2

  • 6
    WaresTreeDataModel is not a WaresDataModel - Grundy
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

The error you mentioned

Inconsistent accessibility: base class 'B' is less accessible than class 'D'

can be obtained when compiling, for example, such code:

 internal class B { } public class D : B { } public class Test { public static void Main() { } } 

The reason, it seems to me, should be obvious from the text of the error. Base class B has a lower access level (visibility) than derived D To fix the problem you need to make the visibility of the classes consistent. For example, both make internal , or both public , or derivative, make it less accessible than basic.