Ok, So Mitch’s blog is definitely getting added to my blog roll. Building on my previous example let’s assume we want to get a list of all the ages of our customers and work with them as a list of int’s rather then dealing with them as a property of the customer, enter Converter<T>.
List<int> allAges = customers.ConvertAll<int>(delegate(Customer customer)
{
return customer.Age;
}
);
Assert.AreEqual(customers.Count, allAges.Count);
allAges.ForEach(delegate(int i)
{
Console.WriteLine(i);
}
);
This allows us to convert all objects in one list to another list. Cool!