Welcome back in the next few videos, I have some amazing stuff for you that will blow your mind and
hopefully not be too much for you, but I'm going to break it down really step by step and very slowly.
And we're going to go into depth in order to understand almost everything that we're going to do.
There is one thing that we will not be able to understand yet, because it would be just a bit too much
to really go into that as well, because delegates is something that we're going to cover later on in
the course, and it will take an hour or so to really dive deep into delegates.
However, we're going to use predicates that are type types of delegates, so to speak.
But we don't need to fully understand delegates in order to be able to use predicates.
And why would we even want to use predicates?
Because there was this keyword in the presentation earlier in the chapter.
So why would we want to use predicates?
Let's have a look at our example here.
So we have our list here right.
Our list of numbers.
And let's add some more numbers in here.
Let's say 25 and 18.
So now I have a bunch of numbers.
What I want to do is I want to find all numbers that are bigger than ten or higher than ten.
How would I do that?
Well, the thing is I can go ahead and use numbers dot and use the find or find all.
So find will just give me one int.
As a result, find all will give me a list of ints as a result.
So this find all method and you can already see it says x equal greater x double equal ten.
So what is going on in this line.
We have seen something like it before.
And I said just ignore it for now.
But now is not the time to ignore it anymore.
So I'm going to explain exactly how that works.
So let's just use this statement here where it really says x equal greater than sign x equal ten.
So what this will do is it will find all tens inside of my list and it will return a list.
However what we're passing into the find all method here is a predicate int match.
So what is a predicate.
Well you can click into it and look into it.
It is a public delegate bool predicate using in like so many keywords that we haven't touched yet.
And it's too early.
So we're using generics here and we're using delegates here.
And as I said, it's way too much for you at this early stage of the course.
However, I'm going to explain to you how to apply it, okay.
How to create a predicate that you can then use in order to find items that fit a certain requirements,
so to speak.
So let's just look at this where we're not going to say equal ten but ten and greater than ten.
And then let's display this list.
So let's actually store this in a side of a list.
After that we're going to go into really understanding exactly what's going on here.
And just understand that this will return a list of numbers that are ten and higher okay.
So that's what this line will do.
Now let's store the result of it.
Because if you hover over find all it says it will return a list of ints.
So let's go ahead and say list or like this list of ints that are higher ten is going to be the name
higher equal ten maybe, or even more precisely higher equal ten.
So that will be the list that will be the result of whatever we do here.
So as you know, if you call a method like we do here on our list, it can return something.
And in this case it does return something.
So it returns a list of items.
So then it will be this higher equal ten.
So let's go ahead and just display all of our numbers.
So all numbers ten and higher in our list of numbers okay.
And I'm going to get rid of this unsorted list.
Well actually let's keep it in there so that we know which items we have in the list.
So now let's run this and we will see our unsorted list is ten, 515, three nine, 25 and 18.
And then it says all number.
Okay I forgot the number ten and higher in our list numbers.
So you see ten, 20 1525 and 18.
So 539 are not ten and higher.
So they are not part of our new list that we created.
Okay.
So that's what happened here.
Now in the next video let's break down what is happening here.
First.
Really understand that before then going into what IT predicate is a little more okay.
So that's it for this video.
As I said don't worry about it.
What you saw here.
We're going to cover it step by step.
All right.
So see you in the next video.