How to determine the object property name dynamically
<p>I have an object User:</p>

<pre><code> public class User
    {

        public String Name { get; set; }


        public String Name2 { get; set; }


        public String Name3 { get; set; }


    }
</code></pre>

<p>Also I have a Key Value set of strings that I want to assign to the object's properties when I create it:</p>

<pre><code>'Name':'srgrgsdfsdf'
'Name3':'dsfdsfafafd'
'Name2':'dtewtwerwer'
'Name4':'546353452552'
</code></pre>

<p>Now I create my object like this</p>

<pre><code>  User user = new User();

  user.Name = "zzxasdas";
</code></pre>

<p>The problem is that I want to be able to assign the Key/Value data dynamically. This means that some of the items can be missing or the order may be different.</p>

<p>How can I check the name of the object properties dynamically and compare it with the Key like this:?</p>

<pre><code>foreach [key] in Key/Value 
if [user] has property named [key] 
add [value] to [user] property with the name [key] 
</code></pre>
