title: Is this a good way to expose generic base class methods through an interface?
body: <p>I am trying to provide an interface to an abstract generic base class.  I want to have a method exposed on the interface that consumes the generic type, but whose implementation is ultimately handled by the classes that inherit from my abstract generic base.</p>
  
  <p>However I don't want the subclasses to have to downcast to work with the generic type (as they already know what the type should be).</p>
  
  <p>Here is a simple version of the only way I can see to get it to work at the moment.</p>
  
  <pre><code>public interface IFoo
  {
      void Process(Bar_base bar);
  }
  
  public abstract class FooBase&lt;T&gt; : IFoo 
      where T : Bar_base
  {
      abstract void Process(T bar);
  
      // Explicit IFoo Implementation
      void IFoo.Process(Bar_base bar)
      {
          if (bar == null) throw new ArgumentNullException();
  
          // Downcast here in base class (less for subclasses to worry about)
          T downcasted_bar = bar as T;
          if (downcasted_bar == null)
          {
              throw new InvalidOperationException(
                            string.Format("Expected type '{0}', not type '{1}'",
                                          T.ToString(), bar.GetType().ToString());
          }
  
          //Process downcasted object.
          Process(downcasted_bar);            
      }
  
  }
  </code></pre>
  
  <p>Then subclasses of FooBase would look like this...</p>
  
  <pre><code>public class Foo_impl1 : FooBase&lt;Bar_impl1&gt;
  {
       void override Process(Bar_impl1 bar)
       {
           //No need to downcast here!
       } 
  }
  </code></pre>
  
  <p>Obviously this won't provide me compile time Type Checking, but I think it will get the job done...</p>
  
  <p>Questions:<br>
   1. Will this function as I think it will?<br>
   2. Is this the best way to do this?<br>
   3. What are the issues with doing it this way?<br>
   4. Can you suggest a different approach?</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>Edit: In Response to many answers, It is a requirement that IFoo is not Generic.  I need to be able to manipulate a collection of IFoo objects regardless of the generic Types they use.</p>
  
  <hr>
  
  <p>Edit: In an effort to clarify the reasoning for this...</p>
  
  <p>Bar_base contains a reference to type IFoo. And must call the process method to validate the data it contains.  Think of IFoo as an object that contains validation logic for the Bar_base derived objects.  When the validity of Bar_base object is questioned, it calls Process on its IFoo reference to validate itself.</p>
  
  <p>The reason IFoo can't be generic is that I need to be able to reference a collection of IFoo independent of the Bar_base classes.</p>
  
  <p>I am going to try the approach of having two interfaces a Generic one that contains the Process method, and non-generic one that doesn't.</p>