title: Loop through ArrayList of objects C#
body: <p>I'm trying to loop through an <strong>ArrayList of objects</strong> of type (people) so i created two classes : </p>
  
  <p><strong>Person.cs</strong></p>
  
  <pre><code>using System;
  
  namespace GenericTypes
  {
      public class Person
      {
          public string FirstName { get; set; }
          public string LastName { get; set; }
          public int Age { get; set; }
          public DateTime DateTime { get; set; }
  
      }
  }
  </code></pre>
  
  <p><strong>People.cs</strong></p>
  
  <pre><code>using System;
  using System.Collections;
  using System.Collections.Generic;
  
  namespace GenericTypes
  {
      public class People
      {
          public ArrayList GetNonGenericPeople()
          {
              var people = new ArrayList()
              {
                  new Person() {FirstName = "Djerah", LastName = "Ahmed Rafik", Age = 23, DateTime = DateTime.Today},
                  new Person() {FirstName = "Djerah", LastName = "Amjed Amir", Age = 11, DateTime = DateTime.Today},
                  new Person() {FirstName = "Gadda", LastName = "Anoir", Age = 25, DateTime = DateTime.Today}
  
              };
              return people;
          }
  
          public  List&lt;Person&gt; GetGenericPeople()
          {
              var people = new List&lt;Person&gt;()
              {
                  new Person() {FirstName = "Djerah", LastName = "Ahmed Rafik", Age = 23, DateTime = DateTime.Today},
                  new Person() {FirstName = "Djerah", LastName = "Amjed Amir", Age = 11, DateTime = DateTime.Today},
                  new Person() {FirstName = "Gadda", LastName = "Anoir", Age = 25, DateTime = DateTime.Today}
  
              };
  
              return people;
          }
      }
  }
  </code></pre>
  
  <p>What i couldn't figure out is how to loop through <strong>GetNonGenericPeople()</strong> so can i output every object with it's properties </p>
  
  <p><strong>program.cs</strong></p>
  
  <pre><code>namespace GenericTypes
  {
      class Program
      {
          static void Main(string[] args)
          {
             var persons = new People();
              var p = persons.GetNonGenericPeople();
  
              foreach (var s in p)
              {
                  Console.WriteLine(s);
              }
          }
      }
  }
  </code></pre>