“ClosureAndVariable” (Solution)
Answer
Explanation
The code is translated into the following form:
The execution of the LINQ queries will start only in the last line of code. As can be seen, the same helper class creates for both queries. First, the list2.Where(displayClass.Method1)
query will be executed. It returns { "Bar", "Baz" }
because displayClass.startLetter
at the time of execution is "B"
. Next, the source.Where(displayClass.Method2)
query will be executed. It also returns { "Bar", "Baz" }
. The number of elements in the result is two.
Last updated