gpt4 book ai didi

C# - foreach 循环的每次迭代都会调用函数吗?

转载 作者:IT王子 更新时间:2023-10-29 04:17:45 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
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.
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com