Demystifying the C# Yield-Return Mechanism: Listing 4.

Selecting Person objects through filters.

List<Person> list1 = new List<Person>();
foreach (Person p in pList) {
  if (p.Name.StartsWith("A") == true)

List<Person> list2 = new List<Person>();
foreach (Person p in list1) {
  if (p.Age < 20)

foreach (Person p in list2)

About the Author

Dr. James McCaffrey works for Microsoft Research in Redmond, Wash. He has worked on several Microsoft products including Azure and Bing. James can be reached at [email protected].

comments powered by Disqus


.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events