Search code examples
asp.netlinqlistienumerableexcept

List<int> except(AnotherList<int>) not return correct results


here is my data:

OldAnswers : 2 NewAnswers : 2 3 4

int Diffcount =  OldCountryAnswers.Except(NewCountryAnswers).Count();

Diffcount is coming out as 0.

Is this right behavior of 'Except' ?

I need difference count between two List<int>.


Solution

  • int Diffcount =  NewCountryAnswers.Except(OldCountryAnswers).Count();
    

    might be what you are looking for, this should give you a count of 2.