Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Inconsistent accessibility: base class 'ClassLibrary3.CDRFinal' is less accessible than class 'ClassLibrary3.CDRList'

What I have tried:

Nothing
Posted
Updated 25-Apr-18 2:16am
v2

Your base class ClassLibrary3.CDRFinal is less accessible (e.g. internal) than the derived class ClassLibrary3.CDRList (e.g. public).

You can fix it by making the base class the same access level as the derived class, or restricting the derived class.

For more details see:
Access Modifiers (C# Programming Guide) | Microsoft Docs[^]
 
Share this answer
 
v2
LMGTFY[^]

Try to use "public" for ClassLibrary3.CDRFinal :)
 
Share this answer
 
v2
The error is self-explanatory. You are probably making CDRList inherit a class called CDRFinal however CDRFinal is less accessible than CDRList, in other words if CDRList is a "public" class then CDRFinal will be "protected" or "private", or something similar.

The solution is to ensure the base class is as accessible as the parent class which involve changing one of their access types to match the other, but we can't tell you what should be changed to match what as we don't know your business rules. It's probably the derived class that needs changed to match the base class.
 
Share this answer
 
Think about it: if class B is derived from class A then class B contains all the properties, methods, and fields of class A as well as any it adds itself.

So to use class B in your app, your code must be able to access all class A features regardless of where it is in the app.

Now suppose you have two Assemblies, one containing classes A and B, and the other trying to use class B only. If class A is not accessible from the second assembly because it is marked as protected, internal, or even private but B is declared as public, the code you write to use it can't access class A at all - so it doesn't know what class B is truly containing and capable of - and you get an "inconsistent accessibility" error as a result.

Either change the access for class A, or for class B, or encapsulate the class A instance in B instead of deriving from it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900