Thursday, November 14, 2024 13:48

Posts Tagged ‘iterator block’

LINQ execution workflow

Wednesday, June 23rd, 2021

In the previous lesson, I talked about the fact that LINQ actually delays the execution of its constituent queries up until the very last moment, when we actually need the data. What was not as obvious at the time was the order in which the LINQ queries are executed.… Read more

Deferred execution

Wednesday, June 9th, 2021

A lot of people seem to think that deferred execution exists because of LINQ, and that is only partially true. LINQ does have a lot to do with it, but deferred execution exists first of all because of the yield statement.… Read more

Yield break statement

Tuesday, May 11th, 2021

Whenever we use the yield keyword in a statement, we indicate that the method, operator, or get accessor in which it appears is an iterator. Of course, since we know that iterators are used to… duh! iterate on collections of data, and since we know that when iterating on a collection, we can use the break keyword to immediately terminate the iteration, it is only obvious that whenever we use an yield return statement to return values in an iterator, like I’ve shown in the previous lesson, we can also use yield break to terminate the iteration of the said iterator.… Read more

Yield return statement

Monday, February 22nd, 2021

In the previous lesson, I have talked about IEnumerable and IEnumerator, and how they help us when we need to iterate over collections of data. Let’s take an example that deals with those concepts:


C# IEnumerable

We have a function, GenerateRandomNumbers(), inside which we declare a List of ints, generate a number of random ints, equal to the _count parameter, add those random ints to the list, then return the list.… Read more


Follow the white rabbit