title: Make method accessible only to other class
body: <p>I have two classes, <code>Sensor</code> and <code>Channel</code>. They are used by "plugging" a sensor in a channel (that is, setting the <code>Sensor</code> property of <code>Channel</code> with a <code>Sensor</code> instance). Then, when you call <code>AddSamples</code> in a <code>Channel</code> with a non-null Sensor, subscribers of <code>Sensor.WhenNewSamples</code> would be notified:</p>
  
  <pre><code>public abstract class Channel
  {
      public Sensor Sensor { get; set; }
  
      public abstract void AddSamples(IEnumerable&lt;double&gt; samples)
  }
  
  public abstract class Sensor
  {
      public abstract IObservable&lt;double&gt; WhenNewSamples { get; }
  
      internal abstract void AddSamples(IEnumerable&lt;double&gt; samples);
  }
  </code></pre>
  
  <p>What I would like to achieve is a way to pass those samples internally, without having to create an exposed <code>Sensor.AddSamples</code>. Also, of course, it should work with subclasses defined in other assemblies, since <code>Sensor</code> and <code>Channel</code> are abstract, and defined in the domain model library.</p>
  
  <p>UPDATE:</p>
  
  <p>The following implementation would be fine, but it doesn't compile because <code>Sensor.AddSamples</code> is internal and the derived classes are in other assemblies:</p>
  
  <pre><code>public class ConcreteChannel : Channel
  {
      public override void AddSamples(IEnumerable&lt;double&gt; samples)
      {
          // AddSamples below is inaccessible
          Sensor.AddSamples(samples);
      }
  }
  
  public class ConcreteSensor : Sensor
  {
      Subject&lt;double&gt; _subject = new Subject&lt;double&gt;();
  
      public override IObservable&lt;double&gt; WhenNewSamples
      {
          get { return _subject.AsObservable(); }
      }
  
      // "No suitable method found to override"
      internal override void AddSamples(IEnumerable&lt;double&gt; samples)
      {
          samples.ToList().ForEach(s =&gt; _subject.OnNext(s));
      }
  }
  </code></pre>