If you look at the Find
definition, public T Find (Predicate<T> match)
, you will see that it receives the Predicate<T>
which is nothing than a function with parametar T
and return value bool
, Func<T, bool>
. This effectively means that the sequence of the elements will be filtered based on the provided function.
One possible way to specify the Func<T, bool>
is using C# language construct called lambda expression. That being said x => x.type == pt...
is an lambda expression which defines the conditions of the element to search for.
Looking at the:
Piece p = Pieces.Find(x => x.type == pt && x.visualIndex == visualIndex)
The intention is to filter Pieces
based on type
and visualIndex
where x
is Piece
. Don't be confused with x
, you could use any literal. You could read it like:
Give me each Piece x where x.type is pt and x.visualIndex is visualIndex