title: Why a function with protected modifier can be overridden and accessible every where?
body: <p>I'm C# programmer new to D language. I'm a bit to confused with OOP in D programming language.</p>
  
  <p>Assuming that I have the following class:</p>
  
  <pre><code>public class A {
     protected void foo() {
        writefln("A.foo() called.");
     }
  };
  
  public class B : A {
     public override void foo() {
        writefln("B.foo() called.");
     }
  };
  </code></pre>
  
  <p>The <code>protected</code> modifier means that I can access the <code>.foo()</code> method just on inherited class,so why this <strong>D</strong> program compiles normally?</p>
  
  <p>Here is the equivalent to <strong>C#.NET</strong>:</p>
  
  <pre><code>using System;
  
  public class A {
     protected virtual void foo() {
        Console.WriteLine("a.foo() called.");
     }
  };
  
  public class B : A {
     public override void foo() {
        Console.WriteLine("b.foo() called.");
     }
  };
  
  public class MainClass  {
     public static void Main(string[] args) {
        A a = new A();
        B b = new B();    
        a.foo();
        b.foo();
     }
  };
  </code></pre>
  
  <p>It don't compiles and given the following error message(as I expected):</p>
  
  <blockquote>
    <p>test.cs(10,30): error CS0507: <code>B.foo()': cannot change access
    modifiers when overriding</code>protected' inherited member `A.foo()'</p>
  </blockquote>
  
  <p>Can someone explain this D behavior? Thanks in advance.</p>