how to remove content of list from anotherlist ?
+1 altho the names `myList` and `myOtherList` are misleading in the context, as they are the exact opposite of the requested "remove ... from anotherlist"
David Hedlund
2010-05-17 10:38:25
@David, good point I will change them
James
2010-05-17 10:40:24
Does this remove objects that are the same object, or object that equal each other (o1.Equals(o2))?
SeaDrive
2010-05-17 19:03:23
@SeaDrive: See http://msdn.microsoft.com/en-us/library/bhkz42b3(VS.80).aspx
James
2010-05-18 07:50:15
A:
Here is a short addition and advise to James post.
If you are using List<T>
and the myOtherList
contains many items you should convert it to a Hashset<T>
var set = new Hashset(myOtherList)
, so his solution should run much faster.
DHN
2010-05-17 10:42:09