Suppose we have these business objects with some properties:
public class A
{
public int Common { get; set; }
public string aValue { get; set; }
}
public class B
{
public int Common { get; set; }
public string bValue { get; set; }
}
And in our business logic, we have two lists:
List<A> aList = new List<A>();
List<B> bList = new List<B>();
(and suppose we have lists filled with at least 100 instances for each) Well, let's start with our problem, we need to iterate over aList to set one property of each instance in bList, which, of course, matches the general property:
foreach (A a in aList)
{
B b = bList.Find(x => x.Common == a.Common);
if (b != null)
b.bValue = a.aValue;
}
Does anyone know a better way to improve this operation, because it causes our application too much time to complete?
thank,
source
share