Suppose I have the following code:
foreach(string str in someObj.GetMyStrings())
{
// do some stuff
}
Will someObj.GetMyStrings() be called on every iteration of the loop? Would it be better to do the following instead:
List<string> myStrings = someObj.GetMyStrings();
foreach(string str in myStrings)
{
// do some stuff
}
?