title: Define optional implementation methods in Interface?
body: <p>Is it possible to define an Interface with optional implementation methods? For example I have the following interface definition as IDataReader in my core library:</p>
  
  <pre><code>public interface IDataReader&lt;T&gt; {
    void StartRead(T data);
    void Stop();
  }
  </code></pre>
  
  <p>However, in my current implementations, the Stop() method has never been used or implemented. In all my implementation classes, this method has to be implemented with throw NotImplementedExcetion() as default:</p>
  
  <pre><code>class MyDataReader : IDataReader&lt;MyData&gt; {
     ...
     public void Stop()
     {
       // this none implementaion looks like uncompleted codes
       throw NotImplementedException();
     }
  </code></pre>
  
  <p>Of course, I can remove the throw exception code and leave it empty.</p>
  
  <p>When I designed this data reader interface, I thought it should provide a way to stop the reading process. Maybe we will use Stop() sometime in the future.</p>
  
  <p>Anyway, not sure if it is possible to make this Stop() method as an optional implementation method? The only way I can think is to either to define two interfaces one with stop and another without such as IDataReader and IDataReader2. Another option is to break this one into to interfaces like this:</p>
  
  <pre><code> interface IDataReader&lt;T&gt; {
      void StartRead(T data);
   }
  
   interface IStop {
      void Stop();
   }
  </code></pre>
  
  <p>In my implementation cases, I have to cast or use as IStop to check if my implementation supports Stop() method:</p>
  
  <pre><code> reader.StartRead(myData);
   ....
   // some where when I need to stop reader
   IStop stoppable = reader as IStop;
   if (stoppable != null ) stoppable.Stop();
   ...
  </code></pre>
  
  <p>Still I have to write those codes. Any suggestions? Not sure if there is any way to define optional implementation methods in an interface in .Net or C#?</p>