I have the following code:
private ScatterViewItem FindScatterViewOfSourceFile(SourceFile find)
{
foreach (ScatterViewItem svi in classScatterViews)
{
if ((svi.Tag as SourceFile).Equals(find))
{
return svi;
}
}
return null;
}
Now I'm asking myself if this is valid or if I should better use:
private ScatterViewItem FindScatterViewOfSourceFile(SourceFile find)
{
ScatterViewItem result = null;
foreach (ScatterViewItem svi in classScatterViews)
{
if ((svi.Tag as SourceFile).Equals(find))
{
result = svi;
break;
}
}
return result;
}
Is there any common practive which one to use? And are both loops doing the same?