Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8349209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:55:31+00:00 2026-06-09T07:55:31+00:00

I have an internal abstract class InternalClassBase and two (also internal) classes InternalClass1 and

  • 0

I have an internal abstract class InternalClassBase and two (also internal) classes InternalClass1 and InternalClass2, which inherit from InternalClassBase.

I also have a public abstract class PublicClassBase and two (also public) classes PublicClass1 and PublicClass2, which inherit from PublicClassBase.

The PublicClassBase has a protected member XXX of type InternalClassBase, so both PublicClass1 and PublicClass2 can use it.

This is my code:

internal abstract class InternalClassBase { }
internal class InternalClass1 : InternalClassBase { }
internal class InternalClass2 : InternalClassBase { }

public abstract class PublicClassBase
{
    protected InternalClassBase XXX;  // this is where the error happens
}
public class PublicClass1 : PublicClassBase { }
public class PublicClass2 : PublicClassBase { }

Why can’t PublicClassBase contain the XXX member in my example? I thought that XXX would only be visible within PublicClassBase, PublicClass1 and PublicClass2, but not outside of it.

I also thought that I understand access modifiers, but obviously I don’t 🙂

Edit – the error happens at declaration of XXX inside PublicClassBase, and the exception message is: Inconsistent accessibility: field type ‘ClassLibrary2.InternalClassBase’ is less accessible than field ‘ClassLibrary2.PublicClassBase.XXX’, but how can protected be more accessible then internal?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:55:32+00:00Added an answer on June 9, 2026 at 7:55 am

    Imagine that in an assembly other than the one types from your example are declared, you declare class PublicClass3 that inherits from PublicClassBase. The field XXX should be visible from PublicClass3, since it is protected, but the type of the field is internal, so at the same time, it should not be visible from PublicClass3.

    Obviously, you cannot have both, hence the error.

    You can solve this either by making your field private, or making PublicClassBase and its children internal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection of classes that inherit from an abstract class I created.
I have forms posting data from instances of a particular abstract class: public abstract
I have the following code internal abstract class Base { public DateTime Time; public
I have the following inheritance: internal abstract class TeraRow{} internal class xRow : TeraRow
I have the following C# code: namespace ISeeOptic.BL { public abstract class Process {
I have got class declared like this: internal private abstract class BoxGroup<TS> : IBoxGroup
I have an abstract base class with a TcpClient field: public abstract class ControllerBase
I have an object derived from an abstract base class and I want to
I have code internal interface IFoo { void foo(); } public class A :
Breaking down the MS RBTree (an internal .Net abstract class), I have discovered that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.