title: Inheriting a template abstract class C#
body: <p>To save myself some writing, you to save you some reading, I constructed a basic example to help me explain what I am trying to achieve.</p>
  
  <p>Say you have a program that uses both a stack class and a queue class, and both classes have the same methods/functions, an optimal choice would probably be to create ab abstract class and inherit it in both classes. If the classes are generic, then the abstract class has to be generic as well. So here's an example of how the abstract class would look like:</p>
  
  <pre><code>public abstract class Sequence &lt;T&gt;
  {
      public abstract void push(T value);
      public abstract T pop();
      public abstract T peek();
      public abstract int size();
      public abstract bool isEmpty();
  }
  </code></pre>
  
  <p>And let's assume that the following is the <code>Stack</code> class that'll need to inherit the <code>Sequence</code> class:</p>
  
  <pre><code>public class Stack&lt;T&gt;
  {
      private List&lt;T&gt; stk;
  
      public Stack ()
      {
          stk = new List&lt;T&gt;();
      }
  
      public void push(T value)
      {
          stk.Add(value);
      }
  
      public T pop()
      {
          T topValue = peek();
          stk.RemoveAt(size () - 1);
          return topValue;
      }
  
      public T peek()
      {
          return stk[size() - 1];
      }
  
      public int size()
      {
          return stk.Count;
      }
  
      public bool isEmpty()
      {
          return size() == 0;
      }
  }
  </code></pre>
  
  <p>Now, my question is, how would you inherit the <code>Sequence</code> class from <code>Stack</code>?
  As you may have noticed already, what I am trying to get right is the syntax, not the functionality of the program. I wasn't able to find a solution that directly applies to my problem.</p>