how to copy a list to a new list, or retrieve list by value in c#

Viewed 22300

I noticed in c# there is a method for Lists: CopyTo -> that copies to arrays, is there a nicer way to copy to a new list? problem is, I want to retrieve the list by value to be able to remove items before displaying them, i dont want the original list to be modified, that too doesnt seem to be easily attainable, any ideas?

7 Answers

It seems if you have a list of references, the list

List<Object> list2 = new List<Object>(list1);

does not work.

This should solve your problem:

How do I clone a generic list in C#?

Related