hey there!
here comes a simple question: how to combine two arraylist without doubles in the result? isnt't there a List method...?
thnx!
hey there!
here comes a simple question: how to combine two arraylist without doubles in the result? isnt't there a List method...?
thnx!
I don't know any ready made function to do this, so maybe just insert one Array completely in a dictionary or hastable and elements from the other array only if the key doesn't exist.
I do this all the time to prevent duplication.... you want to use the HashSet class. It has a UnionWith method that will allow you to do this. You can change the set back to a list if you need a list by 'new List(combinedHashSet);'
Be mindful of the GetHashCode()/Equals() methods if they are a user defined type. Overriding these might cause strange behavior in a hash set. If it's a C# type or a type that does not override these methods you are fine.