My question is like this one:
c# list compare
but the only thing to note is this:
I’m using .NET Framework 2.0
So how can I compare two lists on C# framework 2 and return a boolean value if the items are different?
instance == anotherone fails
instance.Equals(anotherone) fails.
Edit:
They are both List
Edit 2
I’m trying to compare if the list values are exactly. I can sort them, np for that. The problem is if the count or the values of the items changes. For example:
List1->Item1 = "A"
List1->Item2 = "B"
List2->Item1 = "B"
List2->Item2 = "A"
//must return true
List1->Item1 = "A"
List1->Item2 = "B"
List2->Item1 = "B"
List2->Item2 = "C"
//must return false
List1->Item1 = "A"
List1->Item2 = "B"
List2->Item1 = "B"
List2->Item2 = "A"
List2->Item3 = "A"
//must return false, etc.
Thanks and kind regards.
For the question that you link to on computing the intersection, you would need to implement your own version of
Intersect. This should get you started:To handle if they have the same items with the same frequency:
You should probably add some error-handling to the above (first is not null, second is not null). Note that you can’t use
HashSet<T>since you’re in .NET 2.0.