企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
foreach (var item in collection) { // 循环 } ``` int[] fibarray = new int[] { 0, 1, 1, 2, 3, 5, 8, 13 }; foreach (int element in fibarray) { System.Console.WriteLine(element); //0 1 1 2 3 5 8 13 } // 设置集合中元素的计算器 int count = 0; foreach (int element in fibarray) {         count += 1;         System.Console.WriteLine("Element #{0}: {1}", count, element); } System.Console.WriteLine("Number of elements in the array: {0}", count); Element #1: 0 Element #2: 1 Element #3: 1 Element #4: 2 Element #5: 3 Element #6: 5 Element #7: 8 Element #8: 13 Number of elements in the array: 8 ```