How do I copy items from list to list without foreach?

ratty picture ratty · Dec 23, 2009 · Viewed 421.3k times · Source

How do I transfer the items contained in one List to another in C# without using foreach?

Answer

Lasse V. Karlsen picture Lasse V. Karlsen · Dec 23, 2009

You could try this:

List<Int32> copy = new List<Int32>(original);

or if you're using C# 3 and .NET 3.5, with Linq, you can do this:

List<Int32> copy = original.ToList();