What’s the proper way to do this?
foreach(Object obj in ObjectList<Object>)
{
Object changedObject= GetInfo(obj);
obj=changedObject; //no good
obj.prop1 = changedObject.prop1; //ok?
obj.prop2 = changedObject.prop2; //ok?
better way?
}
Use a for loop instead:
You could also use LINQ, and append
.ToList()if you need a list instead of anIEnumerable<T>: