52
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
//obtain a list
10
IEnumerable<Pet> pets = CreateListOfPets();
11
foreach (var dog in GetDogs(pets).Take(2))
12
{
13
Console.WriteLine("retrieved: " + dog.Name + " the " + dog.Animal);
14
}
15
}
16
17
18
public static IEnumerable<Pet> GetDogs(IEnumerable<Pet> pets){
19
List<Pet> dogs = new List<Pet>();
20
foreach (var pet in pets)
21
{
22
Console.WriteLine("Processing: " + pet.Animal);
23
if(pet.Animal=="Dog")
24
{
Cached Result