ForEach-ing only certain objects in a list

Jeremy from Digital Blasphemy brought up the question of how to iterate only over certain objects in a list. In his example, he has a list filled with Cats and Dogs where both are inherited from the base class Animal. What he wanted to do is to use a foreach statement to iterate over the Dogs only without any kind of filtering inside the foreach loop. I pointed out that this is easy to achieve using an anonymous delegate as the predicate in the FindAll method of the List type. The code looks like that:

List<Animal> animals = new List<Animal>();
animals.Add(new Cat("Fluffy"));
animals.Add(new Dog("Spot"));
animals.Add(new Dog("Lucky"));
animals.Add(new Cat("Frisky"));
animals.Add(new Dog("Fido"));
foreach (Dog dog in animals.FindAll(delegate(Animal a) {return a is Dog;}))
  Console.WriteLine("Found a dog named " + dog.Name);


has released the brand new .Net Micro Framework.

The Microsoft .NET Micro Framework is an environment that extends the advantages of Microsoft .NET and the toolset in the Microsoft Visual Studio development system into a class of smaller, less expensive, and more resource-constrained devices than previously possible with other Microsoft embedded offerings.

Let's start playing around.