Merge 2 lists using query syntax

  • Thread starter Thread starter Sems
  • Start date Start date
S

Sems

Hi

I'm trying to add the items in one list to another list using query
syntax. This is what I have so far...

MyList.ForEach(c => MyOtherList.Add(bc));

Is this the best way to do it?

Thanks
 
I'm trying to add the items in one list to another list using query
syntax. This is what I have so far...

MyList.ForEach(c => MyOtherList.Add(bc));

Is this the best way to do it?

MyOtherList.AddRange(MyList);

has been in .NET forever.

If you need it as returning an expression, then one of the
LINQ methods:

MyList.Union(MyOtherList)

or:

MyList.Concat(MyOtherList)

Arne
 
Back
Top