I have two generic lists. Let’s say they are List< A > and List< B >.
ClassA has a property, which type is List< B >. This property contains B type objects, which are filtered by some other proerties of object A.
So:
class A{
public int Something1;
public int Something2;
public List<B> Something3;
}
class B{
public int Anything1;
public int Anything2;
}
I’d like to add all object B as a list to object A (to Property called Something3), where let’s say object A.Something1 == B.Anything1.
My question is: what is the most efficient way of adding List<B> items to List<A> items? Note, there can be hundreds of thousands of objects in both lists.
(VS2010; C#; .Net4)
Group the
B‘s on theAnything1property and put in a dictionary. Then you can loop through theA‘s and efficiently pick out the list ofB‘s: