title: Unable to access protected method in derived class
body: <p>I don't understand why this code gives me an Intellisense error.</p>
  
  <pre><code>public abstract class Node
  {
      protected abstract string ToText();
  }
  
  public class HtmlNode : Node
  {
      public List&lt;Node&gt; ChildNodes { get; set; }
  
      protected override string ToText()
      {
          StringBuilder builder = new StringBuilder();
  
          foreach (var node in ChildNodes)
              builder.Append(node.ToText());  // &lt;=== THIS IS THE ERROR
  
          return builder.ToString();
      }
  }
  </code></pre>
  
  <p>On the line indicated above, I get the error:</p>
  
  <blockquote>
    <p>Error CS1540: Cannot access protected member 'Node.ToText()' via a qualifier of type 'Node'; the qualifier must be of type 'HtmlNode' (or derived from it)</p>
  </blockquote>
  
  <p><code>HtmlNode</code> derives from <code>Node</code>, so why can't <code>HtmlNode</code> access protected members of <code>Node</code>?</p>
  
  <p>And how would I modify the code to use <em>"a qualifier of type <code>HtmlNode</code>"</em>, as suggested in the error message?</p>