title: C# Subclass Best Practice
body: <p>I am currently working on a game in XNA and I'm not sure on how I should go about doing the following...</p>
  
  <p>I have a base class of buildings as such</p>
  
  <pre><code>   public class BuildingsBase
     {
       private int _hp;
       public int hp
       {
          get { return _hp; }
          set { _hp= value; }
       }
  
       private int _woodRequired;
       public int woodRequired
       {
          get { return _woodRequired; }
          set { _woodRequired = value; }
       }
    }
  </code></pre>
  
  <p>I then have multiple subclasses for building types eg.</p>
  
  <pre><code>public class TownHall:BuildingsBase
  {
      public int foodHeld;
  
      public TownHall()
      {
          foodHeld = 100;
          woodRequired = 500;
      }
  }
  </code></pre>
  
  <p>My question is, what is the best way of setting the default values for building subclasses. </p>
  
  <p>For example, the woodRequired for a townhall is set to 500 but at various places in code I need to access this value before I have an instance of townhall declared (When checking if there is enough wood to build). </p>
  
  <p>I currently have a global array of default variables for each building type but im wondering if there is a better way of doing this.</p>
  
  <pre><code>if (Globals.buildingDefaults[BuildingType.Townhall].woodRequired &lt; Globals.currentWood)
  {
      Townhall newTH = new Townhall();
  }
  </code></pre>