Similar to my question about returning from inside a using statement (whose answer was generally "yes, it's ok") I'm wondering if returning from inside a foreach statement is similarly devoid of side-effects and considered accepted practice, or when I do this am I leaving a pointer hanging in the middle an enumeration somewhere internally, etc.
Here's an example:
public string GetCurrentTransaction(string idText)
{
foreach (var transaction in transactions)
{
if (idText.IsEquivalentTo(transaction.IdText))
{
return transaction.Content;
}
}
return "";
}