Tag Archives: yield

Enumerate TreeView nodes in C#

The previous two posts show two ways you can enumerate TreeView nodes that are checked. The idea is to recursively crawl over the tree’s nodes and pick out the checked ones. Unfortunately that method isn’t easily extendable. For example, if … Continue reading

Posted in algorithms, controls, recursion, user interface | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Use the yield statement in C#

An enumeration is a sequence of values that a program can enumerate over, for example, by using a foreach loop. In C# you can use the yield statement to make a method that returns an enumeration. The method that builds … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , | Leave a comment

Use yield to generate prime numbers in C#

  This example is based on a lesson about interfaces that I recently recorded for O’Reilly Video Training.   This example shows how to use the yield return statement to generate prime numbers. More importantly it explains how yield return … Continue reading

Posted in algorithms, mathematics, syntax | Tagged , , , , , , , , , , , , , , | Leave a comment