Update a property on an object knowing only its name
<p>I have some public variables that are defined as follows:</p>

<pre><code>public class FieldsToMonitor
{
    public int Id { get; set; }
    public string Title { get; set; }
    public int Rev {get; set;}
}
</code></pre>

<p>I now want to populate those variable with values, but the <code>fm.[varible name]</code> needs be same as <code>field.Name</code>.  Here how I would populate in loop if I knew the property name ahead  of time and the order of the property name:</p>

<pre><code>// loop 1
fm.Id = revision.Fields[field.Name].Value;

// ... loop 2 ...
fm.Title = revision.Fields[field.Name].Value;

// ... loop 3 ...
fm.Rev = revision.Fields[field.Name].Value;
</code></pre>

<p>Here is what I would like to do where <code>field.Name</code> can be substituted with property name:</p>

<ul>
<li><p>fm.ID becomes
fm.[field.Name] where field.Name == "ID"</p></li>
<li><p>fm.Title becomes
fm.[field.Name] where field.Name == "Title"</p></li>
<li><p>fm.Rev becomes
fm.[field.Name]  and where field.Name == "Rev"</p></li>
</ul>

<p>Is there a solution for this?</p>

<p>Here is more code of what I have so far:</p>

<pre><code>public class FieldsToMonitor
{
    public int Id { get; set; }
    public string Title { get; set; }
    public int Rev {get; set;}
}

static BindingList&lt;FieldsToMonitor&gt; FieldsToMonitorList
     = new BindingList&lt;FieldsToMonitor&gt;();
// ...

// Loop through the work item revisions
foreach (Revision revision in wi.Revisions)
{
    fm = new FieldsToMonitor();
    // Get values for the work item fields for each revision
    var row = dataTable.NewRow();
    foreach (Field field in wi.Fields)
    {
        fieldNameType = field.Name;
        switch (fieldNameType)
        {
            case "ID":
            case "Title":
            case "Rev":
                // the following doesn't work
                fm + ".[field.Name]" = revision.Fields[field.Name].Value; 
                fm[field.Name] = revision.Fields[field.Name].Value;
                row[field.Name] = revision.Fields[field.Name].Value;
                break;
        }
    }
}
</code></pre>
