Looping through Objects properties
<p>How can i loop over an object's properties and get the value of a property.<br>
i have an object that has several properties filled with data. the user specifies what property he wants to view by providing the name of the property, and i need to search for the property in the object and return its value to the user.<br>
 How can i achieve this?<br>
i wrote the following code to get the property but couldn't get the value of that prop:    </p>

<pre><code> public object FindObject(object OBJ, string PropName)
    {
        PropertyInfo[] pi = OBJ.GetType().GetProperties();
        for (int i = 0; i &lt; pi.Length; i++)
        {
            if (pi[i].PropertyType.Name.Contains(PropName))
                return pi[i];//pi[i] is the property the user is searching for,
                             // how can i get its value?
        } 
        return new object();
    }
</code></pre>
