title: C# private (hidden) base class
body: <p>Is it possible to make a C# base class accessible only within the library assembly it's compiled into, while making other subclasses that inherit from it public?</p>
  
  <p>For example:</p>
  
  <pre><code>using System.IO;
  
  class BaseOutput: Stream           // Hidden base class
  {
      protected BaseOutput(Stream o)
      { ... }
  
      ...lots of common methods...
  }
  
  public class MyOutput: BaseOutput  // Public subclass
  {
      public BaseOutput(Stream o):
          base(o)
      { ... }
  
      public override int Write(int b)
      { ... }
  }
  </code></pre>
  
  <p>Here I'd like the <code>BaseOutput</code> class to be inaccessible to clients of my library, but allow the subclass <code>MyOutput</code> to be completely public. I know that C# does not allow base classes to have more restrictive access than subclasses, but is there some other legal way of achieving the same effect?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>My solution for this particular library is to make the base class <code>public</code> and <code>abstract</code>, and to document it with <em>"Do not use this base class directly"</em>. I also make the constructor of the base class <code>internal</code>, which effectively prevents outside clients from using or inheriting the class.</p>
  
  <p>(It's a shame, because other O-O languages let me have hidden base classes.)</p>