In C# I would simply do this:
myIEnumerable.Where(i=>i.ReturnsABool()).any();
How would I do that in VB.net? I'm stuck on how to formulate the lambda..
Lambda expressions can be stored in variables if the variable's type is an interface which has only one method. The lambda expression should have the same number of parameters and the same return type as that method.
The expression num => num * 5 is a lambda expression. The => operator is called the "lambda operator". In this example, num is an input parameter to the anonymous function, and the return value of this function is num * 5 . So when multiplyByFive is called with a parameter of 7 , the result is 7 * 5 , or 35 .
A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression.
Lambda expressions basically express instances of functional interfaces (An interface with single abstract method is called functional interface. An example is java.lang.Runnable). lambda expressions implement the only abstract function and therefore implement functional interfaces.
Try this
myIEnumerable.Where(Function (i) i.ReturnsABool()).Any()
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