/// <summary/>
/// This method returns the value of a property from an object instance
/// using reflection.
/// </summary>
/// <param name="argTargetType">
/// The object instance that contains the property whose value is to be retreived.
/// </param>
/// <param name="argPropertyName">
/// The name of the property whose value is to be retreived.
/// </param>
/// <returns></returns>
public static object GetPropertyValue(object argParentObject,
string argPropertyName)
{
//Get the System.Type of the parent object.
Type objectType = argParentObject.GetType();
if (argParentObject == null
|| objectType == null)
return null;
//Instantiate a PropertyInfo object that corresponds to the required property
PropertyInfo propertyInfo = objectType.GetProperty(argPropertyName);
if (propertyInfo == null)
return null;
//Retrieve the property value as and object
object obj = propertyInfo.GetValue(argParentObject, null);
return obj;
}