title: using reflection to compare object in list
body: <p>I have a 'Invoice' WinForm C# where it contains the usual textboxes and an unbound datagridview. 
  I used a 'Invoice' class object to store the form fields' values. The datagridview rows are stored to a List &lt; SubInvoice> properties in the 'Invoice'.</p>
  
  <pre><code>public static bool CompareObjects(object original, object altered)
  {
      Type o = original.GetType();
      Type a = altered.GetType();
  
      foreach (PropertyInfo p in o.GetProperties(BindingFlags.Public | BindingFlags.Instance))
      {
          Console.WriteLine("Original: {0} = {1}", p.Name, p.GetValue(original, null));
          Console.WriteLine("Altered: {0} = {1}", p.Name, p.GetValue(altered, null));
  
          if (p.GetValue(original, null).ToString() != p.GetValue(altered, null).ToString())
          {
              //Console.WriteLine("Not Equal");
              return false;
          }
      }
  
      return true;
  }
  </code></pre>
  
  <p>I am using a global class with a method that uses Reflection to loop through the original 'invoice' object and compared it with the altered 'invoice'. If there is any difference, the user will be notified to save the invoice.</p>
  
  <p>The above method works fine with all the properties of 'Invoice' class but I do not know how to check for the List in which it stores the value of each datagridrow into a 'SubInvoice' class object that stored it as an object in the list.</p>
  
  <p>Can someone please give me some help here? I have also checked for similar thread in stackoverflow and other forums but in vain.</p>
  
  <p><strong>Update:</strong> I need to create a global generic method that will check for all type of classes. It can be 'Invoice', 'Customer'. The purpose is to track any changes made to the form at any particular instance and prompt the user to save.</p>