I'm trying to write a lambda like below but my syntax is incorrect.
Result = ListOfNumbers.Where(val => { val != Num1; val != Num2; }).ToList()[0];
The error I get is
Not all code paths return a value in lambda expression of type 'System.Func
<int,int,bool>
'
Perhaps there's a better way of doing this... I know there's the numbers 1, 2 and 3 (in that order) in ListOfNumbers. Num1 and Num2 at this point will both be either 1, 2 or 3 (they can't be the same though). I want my result to be the 'other' number from ListOfNumbers. Hope that's clear. If you can think of a neater way of doing it I'd love to hear it.
Any thoughts?