private static string GenerateStr<T>(IList<T> obj, string propName)
{
string str = string.Empty;
foreach(var o in obj)
{
str += o.GetType().GetProperty(propName).GetValue(o, null);
//is there a way to only call above line once, then call
// str =+ o.myStrProp over the course of the iteration?
}
return str;
}
Is there a way to be able to reuse the fetched property to refrain from relying on Reflection to do it again for me. Thanks!
Aucun commentaire:
Enregistrer un commentaire