title: C# dynamically set property
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/619767/net-reflection-set-object-property">.Net - Reflection set object property</a><br>
    <a href="https://stackoverflow.com/questions/1089123/setting-a-property-by-reflection-with-a-string-value">Setting a property by reflection with a string value</a>  </p>
  </blockquote>
  
  
  
  <p>I have an object with multiple properties. Let's call the object objName. I'm trying to create a method that simply updates the object with the new property values.</p>
  
  <p>I want to be able to do the following in a method:</p>
  
  <pre><code>private void SetObjectProperty(string propertyName, string value, ref object objName)
  {
      //some processing on the rest of the code to make sure we actually want to set this value.
      objName.propertyName = value
  }
  </code></pre>
  
  <p>and finally, the call:</p>
  
  <pre><code>SetObjectProperty("nameOfProperty", textBoxValue.Text, ref objName);
  </code></pre>
  
  <p>Hope the question is fleshed out enough. Let me know if you need more details.</p>
  
  <p>Thanks for the answers all!</p>