title: Print List of objects to Console
body: <p>I created a list with Listobj object type. And added a set of values to the object.</p>
  
  <p>How do I print the Listobj objects from the newlist in an increasing age fashion.</p>
  
  <pre><code>class Listobj
  {
      int age;
      string name;
  
      public int Age
      {
          get { return age; }
          set { age = value; }
      }
  
      public string Name
      {
          get { return name; }
          set { name = value; }
      }
  
      static List&lt;Listobj&gt; newlist = new List&lt;Listobj&gt;();
      static void Main(string[] args)
      {
          /*newlist.Add(10);
          newlist.Add(2);
          newlist.Add(6);
          newlist.Sort();
          newlist.ForEach(Console.WriteLine);
          Console.ReadLine();*/
          Listobj obj = new Listobj();
          int tempage = 23;
          string tempname = "deepak";
          obj.Age = tempage;
          obj.Name = tempname;
          Listobj.newlist.Add(obj);
          foreach (Listobj item in newlist)
              Console.WriteLine(item);
          Console.ReadLine();
      }
  }
  </code></pre>