IEnumerable introduces quite a few extensions that help you pass in your own delegate and call the resulting result from IEnumerable. Most of them are Func type
Func takes an argument T and returns TResult.
When
Where is Func: so it takes IEnumerable from T and returns bool. Where ultimately will return IEnumerable from T for which Func returns true.
So, if you have 1,5,3,6,7 as IEnumerable and you write .where (r => r <5), it will return the new IEnumerable from 1,3.
Any - Func is basically similar to a signature, but returns true only when any of the criteria returns true for IEnumerable. In our case, it will return true, since there are several elements with r <5.
Exists - A predicate, on the other hand, will return true only when any of the predicates returns true. Therefore, in our case, if you pass .Exists (r => 5) will return true, since 5 is an element present in IEnumerable.
abhishek Sep 13 2018-10-18 18:51
source share