title: Populate a list with objects of a class
body: <p>I am currently making a game with randomly generated rooms, as I iterate through the newly created rooms to check their coordinates to add them onto a graph I have a list of rooms.</p>
  
  <pre><code>list&lt;Room&gt; listOfAllRooms;
  </code></pre>
  
  <p>I can continue with the clunky way of specifying where all the room objects are stored. </p>
  
  <pre><code>list&lt;Room&gt; listOfAllRooms = new List&lt;Room&gt; {roomObject.room1, ...}
  </code></pre>
  
  <p>They are stored in another class just to keep things tidy, exactly like so...</p>
  
  <pre><code>public class RoomObjects { public static Room room1 = new Room(); .....}
  </code></pre>
  
  <p>All the way for 25 rooms.</p>
  
  <p>This is messy beyond all belief and will create a serious issue should I expand beyond the current 25 rooms I am currently working with.
  In my mind there should exist a way to populate this list of all the rooms directly from one neat and tidy source.
  So really my question boils down to is there a better way to declare these objects and store them into a list automatically? or if not at least a way to add each room into a list automatically?</p>
  
  <p>(Note, I have a large part of the code working with a list of all rooms so i hope i don't have to re-write that to fix this)</p>