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 9169367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:52:07+00:00 2026-06-17T15:52:07+00:00

protected internal class foo { //this compiles without any errors } also internal class

  • 0
protected internal class foo
{
    //this compiles without any errors
}

also

internal class bar
{
    public int quix;
    protected internal int zyx;
    //this compiles without any errors
}

Are these compiler bugs or my misinterpretation of the standard?

Explanation:

  1. Classes can’t have protected internal access modifier, only public or internal according to MSDN (Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified).
  2. Not all access modifiers can be used by all types or members in all contexts, and in some cases the accessibility of a type member is constrained by the accessibility of its containing type (MSDN). Public should fail. Protected internal is ambiguous for me – internal modifier is not necessary.

Edit: The fact that I’m using Mono is unnecessary cause the question was about what standard says and not what MONO does or does not. Maybe I’m coding my own compiler. That’s why I quoted MSDN to be precise what is allowed and what is not.

  • 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-17T15:52:10+00:00Added an answer on June 17, 2026 at 3:52 pm

    As mentioned in my comment above, protected internal means protected or internal NOT protected and internal. No bug here 🙂

    Further information/explanation is on haacked

    In response to your questions:

    1. A class within a namespace (and not within another class) can only be declared as public or internal. HOWEVER, a class within another class can be declared as protected internal, private, etc.

    2. Yes, protected internal can be used inside a class whose access modifier is more strict than it’s members, see example of a perfectly valid usage below (note that the class is inside the Program class):

      public class Program
      {
          static void Main(string[] args)
          {
          }
      
          private class Foo
          {
              private int priv { get; set; }
              protected internal int protint { get; set; }
              public int pub { get; set; }
          }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is wrong with this?: public abstract class EFNLBaseRepository:IDisposable { NLSubscriberDBContext _dbContext; protected internal
Protected Means, we can access this member only in a deriving class, and internal
Below is a simple testing code: public class A { protected int m =
If I have a class with a method I want protected and internal .
This question is similar to c# internal abstract class, how to hide usage outside
This class property is what I'm trying to refactor into an interface. public class
This is really two questions, noted below: Currently I have some public internal helper
Assume the following schema class Person{ public int Id {get;set;} public virtual ICollection<Province> Provinces
Here is my module internal class WebServiceConfiguration : NinjectModule { public override void Load()
I have a code like this: public abstract class DataContextBase { public DbContext DbContext

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.