I have a custom type MyType
with a function MyBoolFunction(string)
that returns true or false.
I have a large list of MyType
objects MyTypeList
.
I have a list of string objects StringList
.
I would like to get the subset of MyTypeList
where myTypeList.MyBoolFunction(arg)
is true for at least one value of arg
as arg
ranges over StringList
.
I think I should be able to do this with C# lambda expressions.
I imagine something like this (pseudocode)
MyTypeList.Where(x => (x.MyBoolFunction(arg)==true for some arg in StringList);
Is this possible? How can I do this?
Try using Enumerable.Any
:
var query = MyTypeList.Where(x => StringList.Any(arg => x.MyBoolFunction(arg)));
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