Tim Van Wassenhove home

Here is a real-life example of when people are much better expressing intent than a tool: Consider the following code from a typical Silverlight Navigation application

foreach (UIElement child in LinksStackPanel.Children)
{
	var hb = child as HyperlinkButton;
	if (hb != null && hb.NavigateUri != null)
	{ .. }
}

Resharper proposed to write this as following

foreach (var hb in LinksStackPanel.Children
	.Select(child => child as HyperlinkButton)
	.Where(hb => hb != null && hb.NavigateUri != null))
	{ .. }

Here is what i wrote instead

foreach (var hb in LinksStackPanel.Children
	.OfType<hyperlinkButton>()
	.Where(hb => hb.NavigateUri != null))
	{ .. }