Can someone explain why this doesn't work like I think it should.
double[] numbers1 = { 2.0, 2.1, 2.2, 2.3, 2.3, 2.3, 2.4, 2.5 };
double[] numbers2 = { 2.2 };
IEnumerable<double> onlyInFirstSet = numbers1.Except(numbers2);
foreach (double number in onlyInFirstSet)
Console.WriteLine(number);
/*
This code produces the following output:
2
2.1
2.3
2.4
2.5
*/
What I would expect is 2, 2.1, 2.3, 2.3, 2.3, 2.4, 2.5. Why would except return a distinct list? Is this a bug?
Update:
Ok, totally missed that point in the docs. Funny 4 people respond with the same answer. You would think you would just up vote the guy who answered it first.:)