Tim Van Wassenhove home

A couple of weeks ago i discovered [Enumerable.OfType](http://msdn.microsoft.com/en-us/library/bb360913.aspx) when i let Resharper rewrite my code as a Linq statement. Here is the original code:

var selectedPersons = new List<personSelectItem>();
foreach(var selectedItem in selectedItems)
{
	var selectedPerson = selectedItem as PersonSelectItem;
	if (selectedPerson == null) continue;
	selectedPersons.Add(selectedPerson);
}

And here is how it looks after the rewrite:

var selectedPersons = selectedItems.OfType<personSelectItem>().ToList();

Yup, the Resharper license was definitely worth it’s money.