I have a List of some object which has multiple properties with prefix before and after in there name. few properties of class
class foo
{
public string before_value1 { get; set; }
public string before_value2 { get; set; }
public string before_value3 { get; set; }
public string before_value4 { get; set; }
public string after_value1 { get; set; }
public string after_value2 { get; set; }
public string after_value3 { get; set; }
public string after_value4 { get; set; }
}
let the name of the class is foo and I have some object collection
List<foo> objFooList(having size of more then 1000)
I Want to loop through collection object and swap all the values of before properties with after properties.
objFooList.ForEach(x=>{
x.before_value1=x.after_value1;
x.before_value2=x.after_value2;
x.before_value3=x.after_value3;
x.before_value4=x.after_value4;
})
here I am mentioning only few fields of class but I have multiple fields and I don't want to manually do this by typing name of each field.
Aucun commentaire:
Enregistrer un commentaire