【发布时间】:2010-03-15 13:47:52
【问题描述】:
可能重复:
How does foreach work when looping through function results?
如果我具有以下功能 - ReturnParts() 会在 foreach 循环中的每次迭代中被调用,还是只会被调用一次?
private void PrintParts()
{
foreach(string part in ReturnParts())
{
// Do Something or other.
}
}
private string[] ReturnParts()
{
// Build up and return an array.
}
【问题讨论】: