Enumerate Object Array in C#

In this article I will explain that how to enumerate an array of objects.
  • 3007

C# also provides us with Enumerators to allow us enumerate through the elements within the objects.

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();

        }

 

    }

}

Output

enum_datatype.jpg

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.