I have a list of a class object
lets say the class is structured like this
class DataEntity
{
public string col1 { get; set; }
public string col2 { get; set; }
public string col3 { get; set; }
}
so the list would be
List<DataEntity> list = new List<DataEntity>
So here is my issue I need to loop through list and modify the value of a specific property..but I don't know what property need to be modified until run time.
so lets say there is a Method that converts the list and the property name to be modified is passed in as a string value
public List<DataEntity> Convert (List<DataEntity> list, string propertyName, string appendedValue)
{
}
SO my question is how can I loop though that list and for the propertyName entered append the appendedValue to that properties value
I know I can get the proeprties values using reflection like this
Type type = dataEntity.GetType();
foreach (PropertyInfo pi in type.GetProperties())
{
}
but I'm not sure how that can be leveraged to target a specific property for appending at runtime.