title: Property and name at runtime from a class
body: <p>I have a class</p>
  
  <pre><code>public class ProjectTask
  {
      public ProjectTask();
  
  
      [XmlElement("task_creator_id")]
      public string task_creator_id { get; set; }
      [XmlElement("task_owner_id")]
      public string task_owner_id { get; set; }
      [XmlElement("task_owner_location")]
      public TaskOwnerLocation task_owner_location { get; set; }
      [XmlElement("task_owner_type")]
      public string task_owner_type { get; set; }
      [XmlElement("task_type_description")]
      public string task_type_description { get; set; }
      [XmlElement("task_type_id")]
      public string task_type_id { get; set; }
      [XmlElement("task_type_name")]
      public string task_type_name { get; set; }
  }
  </code></pre>
  
  <p>An xml will be deserialized to this at runtime.</p>
  
  <p>Is there way to get the field name and value?</p>
  
  <p>Using reflection I can get the property names like so:</p>
  
  <pre><code>PropertyInfo[] projectAttributes = typeof(ProjectTask).GetProperties();
  </code></pre>
  
  <p>A foreach loop can be applied to get the properties</p>
  
  <pre><code>foreach(PropertyInfo taskName in projectAttributes)
         {
             Console.WriteLine(taskName.Name);
         }
  </code></pre>
  
  <p>but how do I print the property and the value?
  Like 
      task_creator_id = 1</p>
  
  <p>where task_Id is one of the properties and the value of that at runtime is 1.</p>