可能重复:
循环功能结果时foreach如何工作?
如果我具有以下功能 - 将在foreach循环中为每次迭代调用ReturnParts(),还是只调用一次?
private void PrintParts()
{
foreach(string part in ReturnParts())
{
// Do Something or other.
}
}
private string[] ReturnParts()
{
// Build up and return an array.
}
Run Code Online (Sandbox Code Playgroud)