title: Using the value in one array to set the object in another
body: <p>I am stuck trying to figure out how to use the values of one array of numbers to initialize a second array of objects. This might not be the most effective way to do something like this in a real program, but I am just trying to understand how to create a relationship between two different arrays.
      The first array is just a randomly generated array holding values 0,1 or 2. The second array is an array of Occupant objects. Each occupant has an occupant id that will be either 0, 1 or 2. I am trying to generate the second array of occupants by copying the values of first array and then initializing the second based on the occupant id. 
      Nothing I have tried will compile, and I can't think of anything else on my own except writing a million if statements. Surely there must be a simple solution I am missing. Any help you can offer will be greatly appreciated. </p>
  
  <p>FYI: Occupant is the base class, three classes derive from it, each with a unique id number.</p>
  
  <pre><code>static public class Board
  {
      static public Occupant[,] board = BoardGen();
      static private Occupant[,] BoardGen()
      {
          Random myRandom = new Random();
          int[,] setup = new int[10, 10];
          for (int i = 0; i &lt; setup.GetLength(0); i++)
          {
              for (int j = 0; j &lt; setup.GetLength(1); j++)
                  setup[i, j] = myRandom.Next(0, 3);
          }
  
          Occupant[,] populate = new Occupant[10,10];
  
          // How to link setup to populate using the number to choose an occupant based on it's id number?
  
          return populate;
      }
  }
  </code></pre>
  
  <p>}</p>