title: Add created objects to List automatically
body: <p>I have a simple class </p>
  
  <pre><code>class Employee
      {
          public int EmployeeId { get; set; }
          public string FirstName { get; set; }
          public string LastName { get; set; }
          public DateTime HireDate { get; set; }
  
          public Employee() 
          { 
          }
  
          public static Employee GetNewestEmployee(List&lt;Employee&gt; e)
          {
              Employee emp = e.OrderByDescending(x =&gt; x.HireDate).FirstOrDefault();
              Console.WriteLine("The newest employee was hired on {0}",emp.HireDate);
              return emp;
          }
  </code></pre>
  
  <p>The method will return the employee who was most recently hired.  In my Main method I have something like</p>
  
  <pre><code>Employee e = new Employee();
              e.EmployeeId = 101;
              e.FirstName = "Tom";
              e.LastName = "Jones";
              e.HireDate = DateTime.Now.Subtract(TimeSpan.FromDays(40));
  
              Employee e2 = new Employee();
              e2.EmployeeId = 102;
              e2.HireDate = DateTime.Now.Subtract(TimeSpan.FromDays(100));
  
              Employee e3 = new Employee();
              e3.EmployeeId = 103;
              e3.HireDate = DateTime.Now.Subtract(TimeSpan.FromDays(1000));
              List&lt;Employee&gt; empList = new List&lt;Employee&gt;();
              empList.Add(e);
              empList.Add(e2);
              empList.Add(e3);
  
              Console.WriteLine(Employee.GetNewestEmployee(empList).EmployeeId);
  
          }
  </code></pre>
  
  <p>all of this works well enough but I was wondering what would the solution be if you didn't know how many Employee objects were going to be created, or there were 1000s of employee objects created.  How can one do something like <code>foreach(object o thatHasBeenInstantiated)</code>?</p>