枚举C#中的对象数组

在本文中,我将解释如何枚举一个对象数组。
在C#中如何遍历数组?
C#如何循环访问数组中的每个元素?
C#向我们提供了枚举器,允许我们枚举对象内的元素。

namespace demo_array

{
    class Program

    {

        static void Main(string[] args)
        {

            int[] numbers = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
            IEnumerator e = numbers.GetEnumerator();
            while (e.MoveNext())
            {

                Console.WriteLine(e.Current);
            }
            Console.ReadKey();
        }

    }
}
日期:2020-04-11 22:50:28 来源:oir作者:oir