title: Get C# Property Values for multiple objects
body: <p>I have couple of domain objects something like:</p>
  
  <pre><code>public class Person()
  {
  public int age { get; set; }
  public string city{ get; set; }  
  }
  
  public class Company()
      {
      public string name{ get; set; }
      public string address{ get; set; }  
      }
  </code></pre>
  
  <p>I have another class which calls the MyMethod as mentioned below.</p>
  
  <pre><code>public class CallTest()
  {
   Person p= new Person{age=10,city="dd"};
   Company c= new Company{name="mynae",address="myaddress"};
   MyMethod(p);
   MyMethod(c);
  }
  </code></pre>
  
  <p>mi.Name gives me the property name. But how do I get the property value?</p>
  
  <pre><code>public class MyMethod(object obj)
  {
      Type t = obj.GetType();
      PropertyInfo prop = t.GetProperty("Items");
      foreach (MemberInfo mi in t.GetMembers())
              {
                      if (mi.MemberType == MemberTypes.Property)
                      {
                         var x = mi.Name;
                      }
                  }
  }
  </code></pre>