🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
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 ```