I want access to a property value by its name. The only way i know it's by reflection with a code like this:
public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}
Are there others ways to do it (using ex. codegen, etc.)?
Aucun commentaire:
Enregistrer un commentaire