title: Abstract class for classes with different types of parameters
body: <p>I'm pretty new to C# and I believe similar question has been answered already, but am not sure what to search for, so here is the question: </p>
  
  <p>I have two classes that have some identical methods and constructors. However, these methods and constructors accept different types of parameters (the Dictionaries variables are different). So how do I put these methods and constructors into abstract class <code>Brain</code>?</p>
  
  <p><strong>Brain.cs</strong></p>
  
  <pre><code>public abstract class Brain
  {
      protected int width;
      protected int height;
  }
  </code></pre>
  
  <p><strong>Reward.cs</strong></p>
  
  <pre><code>public class Reward:Brain
  {
  
      public Dictionary&lt;Tuple&lt;Point, Direction&gt;, int&gt; r = 
                new Dictionary&lt;Tuple&lt;Point, Direction&gt;, int&gt;();
      public Reward(int w, int h)
      {
          int directionsCount = Enum.GetNames(typeof(Direction)).Length;
          int direction;
          width = w;
          height = h;
          for (int i = 0; i &lt; w; i++)
              for (int j = 0; j &lt; h; j++)
                  for (direction = 0; direction &lt; directionsCount; direction++)
                  {
                      Point state = new Point(i, j);
                      r[Tuple.Create(state, (Direction)direction)] = 0;
                  }
      }
      public void Set(Point state, Direction direction, int reward)
      {
          r[Tuple.Create(state, direction)] = reward;
      }
      public int Get(Point state, Direction direction)
      {
          return r[Tuple.Create(state, direction)];
      }       
  }
  </code></pre>
  
  <p><strong>Quantity.cs</strong></p>
  
  <pre><code>public class Quantity:Brain
  {   
      public Quantity(int w, int h)
      {
           .........
          for (int i = 0; i &lt; width; i++)
              for (int j = 0; j &lt; height; j++)
                  for (direction = 0; direction &lt; directionsCount; direction++)
                  {
                      Point state = new Point(i, j);
                      Set(state, (Direction)direction, 0);
                  }
      }
      private Dictionary&lt;Tuple&lt;Point, Direction&gt;, decimal&gt; q =
              new Dictionary&lt;Tuple&lt;Point, Direction&gt;, decimal&gt;();         
           .....
      public decimal Get(Point state, Direction action)
      {
          return q[Tuple.Create(state, action)];
      }
      public void Set(Point state, Direction action, decimal value)
      {
          q[Tuple.Create(state, action)] = value;
      }           
  }
  </code></pre>