I have List , I; only want to select base on certain criteria with LinQ/LAMBDA
My Code is
Lists.ForEach(x => x.IsAnimal == false { /* Do Something */ } );
I am getting error "only assignment, call, increment, decrement and new object expressions can be used as a statement" in this part x.IsAnimal == false
i know we can achieve this easily with a for loop but I want to learn more by using LinQ/LAMBDA
Just use Where and ToList before using ForEach
Lists.Where(x => !x.IsAnimal).ToList().ForEach(...)
That's not working because you can't have false{}
construct.
Lists.ForEach(x => {
if(x.IsAnimal){
//Do Something
}
} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With