From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Customize a method with predicate functions

Customize a method with predicate functions - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Customize a method with predicate functions

- [Narrator] In this video, our goal is to explore how to use the FindAll function shown on line 17. This function is defined within the List<T> class. This method allows us to retrieve all the elements in the list that match a specified condition. Along the way, we'll learn more about predicate functions, delegates, and lambda expressions. So if you look at the signature of this method, its purpose is to find items based on some code that I'll provide. The signature says FindAll will return a List of Integer, and it expects me to pass in an instance of a Predicate of Integer. I've defined a function that matches the signature, up here. Now predicate, as you recall, has to return a Boolean, and the purpose is to examine one value and determine whether it should be in the results, the output. Now of course, this function only works with one number at a time, but this function will get called multiple times by the FindAll method down here. W does my code do? It takes a number as an…

Contents