title: How can I write these methods in a more generic way in c#?
body: <p>I have the following class hierarchy:</p>
  
  <p><code>EstadoBaseMO</code> (parent)</p>
  
  <ul>
  <li><code>EstadoSAMO(EstadoBaseMO child)</code></li>
  <li><code>EstadoGesDocMO(EstadoBaseMO child)</code></li>
  </ul>
  
  <p><code>SolicitudBasePresenter</code>(parent)</p>
  
  <ul>
  <li><code>SolicitudGesDocPresenter(SolicitudBasePresenter child)</code></li>
  <li><code>SolicitudSAPresenter(SolicitudBasePresenter child)</code>     </li>
  </ul>
  
  <p><code>EstadoBaseBO</code>(parent)</p>
  
  <ul>
  <li><code>EstadoGesDocBO(EstadoBaseBO child)</code></li>
  <li><code>EstadoSABO(EstadoBaseBO child)</code>    </li>
  </ul>
  
  <p>I need to implement a method called <code>SaveNewDetailStates</code>, with the following implementation in <code>SolicitudBasePresente</code> is</p>
  
  <pre><code>public bool SaveNewDetailStates(List&lt;EstadoBaseMO&gt; estados)
      {
          bool result = true;
  
          if (estados.Any())
          {
              try
              {
                  EstadoGesDocBO bo = new EstadoGesDocBO();
  
                  foreach (var estado in estados)
                  {
  
                      var savedState = bo.Insert(estado);
                      result &amp;= ((savedState != null) &amp;&amp; (savedState.Id != estado.Id));
                  }
              }
              catch (Exception ex)
              {
                  result = false;
              }
          }
          return result;
      }
  </code></pre>
  
  <p><code>SolicitudGesDocPresenter.SaveNewDetailStates</code> implementation</p>
  
  <pre><code>public bool SaveNewDetailStates(List&lt;EstadoGesDocMO&gt; estados)
      {
          bool result = true;
  
          if (estados.Any())
          {
              try
              {
                  EstadoGesDocBO bo = new EstadoGesDocBO();
  
                  foreach (var estado in estados)
                  {
  
                      var savedState = bo.Insert(estado);
                      result &amp;= ((savedState != null) &amp;&amp; (savedState.Id != estado.Id));
                  }
              }
              catch (Exception ex)
              {
                  result = false;
              }
          }
          return result;
      }
  </code></pre>
  
  <p><code>SolicitudSAPresenter.SaveNewDetailStates</code> implementation</p>
  
  <pre><code> public bool SaveNewDetailStates(List&lt;EstadoSAMO&gt; estados)
      {
          bool result = true;
  
          if (estados.Any())
          {
              try
              {
                  EstadoSABO bo = new EstadoSABO();
  
                  foreach (var estado in estados)
                  {
  
                      var savedState = bo.Insert(estado);
                      result &amp;= ((savedState != null) &amp;&amp; (savedState.Id != estado.Id));
                  }
              }
              catch (Exception ex)
              {
                  result = false;
              }
          }
          return result;
      }
  </code></pre>
  
  <p>As you can see, the code is exactly the same with two differences, in <code>SolicitudSAPresenter</code> I'm using <code>EstadoSAMO</code> and <code>EstadoSABO</code> classes, similar in <code>SolicitudGesDocPresenter</code>.
  Things to know:</p>
  
  <ul>
  <li>I don't really need an implementation of <code>SolicitudBasePresenter.SaveNewDetailStates</code></li>
  <li>I tried to convert the parent method(<code>SolicitudBasePresenter.SaveNewDetailStates</code>) to an abstract method, but then, the <code>SAPresenter</code> and <code>GesDocPresenter</code> can't use override because they need to implement the same signature (and it's not the same..), besides, soon after I realized I need a concrete implementation of <code>SolicitudBasePresenter</code>, so it shouldn't be an abstract class (similar happens with a virtual method)</li>
  <li>Maybe the use of generics can solve that problem, but I'm still not used to them. I tried with something like <code>SaveNewDetailStates&lt;T,K&gt;(List&lt;T&gt; estados)</code>, but then I'm lost and I don't know what else can I do.</li>
  </ul>
  
  <p>What is the best approach for writing this code? </p>
  
  <p>The only solution I have is to delete the <code>SaveNewDetailStates</code> from parent presenter, and write the concrete implementation in children and then everything is fine but...I don't think that's even a solution for a good developer..</p>