> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C# Protected Internal Property

A `protected internal` property in C# is a class member whose access level is a logical OR combination of the `protected` and `internal` access modifiers. It is accessible to any code within the same assembly, as well as to any derived class, regardless of whether that derived class resides in the same assembly or a different one.

## Syntax

The modifier is applied directly to the property declaration. The order of the keywords `protected` and `internal` does not matter, though `protected internal` is the standard convention.

```csharp theme={"dark"}
public class BaseClass
{
    protected internal string ConfigurationState { get; set; }
}
```

## Accessibility Rules

The compiler evaluates access to a `protected internal` property based on two distinct boundaries: the assembly boundary and the inheritance hierarchy.

1. **Within the Same Assembly (`internal` behavior):** Any type (class, struct, etc.) within the same compiled assembly can access the property, regardless of whether it inherits from the declaring class.
2. **Outside the Assembly (`protected` behavior):** A type in a different assembly can only access the property if it explicitly derives from the declaring class.

### Cross-Assembly Instance Restriction

When accessing a `protected internal` property from a derived class in a *different* assembly, the access must occur through an instance of the derived class type (or a type derived from it). You cannot access the property through an instance typed as the base class.

## Code Visualization

The following example demonstrates the compiler's behavior across two different assemblies.

**Assembly A**

```csharp theme={"dark"}
public class CoreSystem
{
    protected internal int SystemThreshold { get; set; }
}

public class SiblingComponent
{
    public void ModifyThreshold(CoreSystem system)
    {
        // Valid: Accessed within the same assembly (Internal rule applies)
        system.SystemThreshold = 100; 
    }
}
```

**Assembly B (References Assembly A)**

```csharp theme={"dark"}
public class ExtensionSystem : CoreSystem
{
    public void UpdateThreshold()
    {
        // Valid: Accessed from a derived class (Protected rule applies)
        this.SystemThreshold = 200; 

        CoreSystem baseInstance = new CoreSystem();
        // INVALID: Compiler Error CS1540. 
        // Cannot access protected member via a qualifier of type 'CoreSystem'.
        // baseInstance.SystemThreshold = 300; 
    }
}

public class UnrelatedSystem
{
    public void AttemptModification(CoreSystem system)
    {
        // INVALID: Compiler Error CS0122.
        // Inaccessible due to its protection level (Not internal, not protected).
        // system.SystemThreshold = 400; 
    }
}
```

## Technical Distinction: `protected internal` vs. `private protected`

It is critical to distinguish `protected internal` from `private protected`, as they represent opposite logical operations:

* **`protected internal` (Logical OR):** Accessible if the caller is in the same assembly **OR** is a derived class. It expands accessibility.
* **`private protected` (Logical AND):** Accessible *only* if the caller is in the same assembly **AND** is a derived class. It restricts accessibility.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C# Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
