title: Passing derived type as argument to abstract class
body: <p>I was wondering if it is possible to implement a similar signature to the below code in c#:</p>
  
  <pre><code>public abstract class baseClass
  {
      public abstract float function(derivedType a, derivedType b);
  }
  
  public class derived: baseClass
  {
      public override float function(derived a, derived b)
      {
          return something to do with a and b;
      }
  }
  </code></pre>
  
  <p>Hopefully it's clear what I'm trying to do from that, cheers.</p>
  
  <p>Edit: I tried the below with no success, hopefully it might also clarify what I'm trying to do:</p>
  
  <pre><code>public abstract class baseClass
  {
      public abstract float function&lt;T&gt;(T a, T b) where T:baseClass;
  }
  
  public class derived: baseClass
  {
      public override float function&lt;derived&gt;(derived a, derived b)
      {
          return a.value + b.value;
      }
  
      public float value;
  }
  </code></pre>
  
  <p>Apparently derived doesn't contain a definition for 'value' according to visual studio.</p>
  
  <p>Edit, SOLUTION:</p>
  
  <pre><code>public abstract class baseClass&lt;T&gt; where T: baseClass&lt;T&gt;
  {
      public abstract float function(T a, T b);
  }
  
  public class derived : baseClass&lt;derived&gt;
  {
      public override float function(derived a, derived b)
      {
          return a.value + b.value;
      }
  
      public float value;
  }
  </code></pre>
  
  <p>Thanks everyone for the help :)</p>