title: Update a class property using reflection and the name of the property as a string
body: <p>I have a sample class</p>
  
  <pre><code>public class sampleClass
  {
      public string givenName { get; set; }
      public string familyName { get; set; }
  }
  </code></pre>
  
  <p>and a set of values for that class contained in <code>IDictionary&lt;string, object&gt; dataModel</code>. I can use reflection to iterate through the <code>dataModel</code> and use the <code>dataModel</code> key to get the value.</p>
  
  <p>I would like to do something like:</p>
  
  <pre><code>void UpdateValues(IDictionary&lt;string, object&gt; dataModel)
  {
      Type sourceType = typeof(sampleClass);
      foreach (PropertyInfo propInfo in (sourceType.GetProperties()))
      {
          if (dataModel.ContainsKey(propInfo.Name))
          {
              //  set propInfo value here
              propInfo.Value = dataModel[propInfo.Name];
          }
      }
  }
  </code></pre>
  
  <p>But i have no idea how to do the line </p>
  
  <pre><code>propInfo.Value = dataModel[propInfo.Name];
  </code></pre>
  
  <p>Help! Thanks !!</p>