I have a task to find even or odds numbers in a list using LINQ lambda. I simply have this code to do it, but the compiler says "not all code paths return a value in lambda expression". So I think I need a default value, but how can I implement it? I tried a few things but still don't work. Please give advice. Thanks.
list = list.Where(x =>
{
if (command == "odd")
return x % 2 != 0;
else if (command == "even")
return x % 2 == 0;
});