title: Convert string to variable name
body: <p>I have an XML file, I have a node and I read all ChildNodes. The name of the childNode match to a variable I have to set with the value of this childNode.</p>
  
  <p>In the loop, I'd like set :</p>
  
  <ul>
  <li>myvar1 to MyValue1</li>
  <li>myvar2 to MyValue2</li>
  </ul>
  
  <p>The C# Code : </p>
  
  <pre><code>protected string myvar1;
  protected string myvar2;
  </code></pre>
  
  <p>The XML content look like this :</p>
  
  <pre><code>&lt;parameters&gt;
   &lt;myvar1&gt;MyValue1&lt;/myvar1&gt;
   &lt;myvar2&gt;MyValue2&lt;/myvar2&gt;
  &lt;/parameters&gt;
  </code></pre>
  
  <p>C# set variables : </p>
  
  <pre><code>    foreach (var item in xmlParamInstallation.SelectNodes("parameters")[0].ChildNodes)
      {
          ??????
      }
  </code></pre>
  
  <p>Any idea ?</p>
  
  <p>Thanks,</p>
  
  <p><strong>UPDATE 1:</strong>
  the value "field" in the loop is null all the time.</p>
  
  <pre><code>public class ParametersTest
  {
      public string myvar1 { get; set; }
      public string myvar2 {get; set;}
  }
  
  var type = typeof(ParametersTest);
  foreach (XmlNode item in xmlParamInstallation.SelectNodes("parameters")[0].ChildNodes)
  {
  
      var field = type.GetField(item.LocalName);
      field.SetValue(field, item.InnerText);
  }
  </code></pre>