How to clone list in c#

static class Extensions { public static IList Clone(this IList . you can instead use the GetRange method of the generic List class. If you want to clone each Item in the list you can implement ICloneable on EDIT : To make it a bit clearer both will copy the elements from list a1 into a new list. If you want to copy the entire list to a new list, you could do something like the following: List newWidgetList = new.

Return a deep clone of a list. public static List DeepClone(this List items) { var query = from T item in items select rxkjftu.gaone();. C#. Hello, My problem is about the copy of object without reference. What I have tried: I try to copy a list of object like this: Hide Copy Code. A shallow copy is useful if we want to sort the list. In that case we specifically don't want a deep copy. We don't want to duplicate the list items, only the list object.

This C# program uses the CopyTo method on the List type. It creates an array. Clone. A full-featured language includes methods that may not be recommended. In C# (for example) the Clone method and ICloneable interface are available. How to copy or clone a C# list - To copy or clone a C list firstly set a list List string list1 new List string list1 Add One list1 Add Two list1 Add.