2
Answers

NP97 GetEnumerator()

Maha

Maha

16y
2.1k
1

Hi Guys

 

NP97 GetEnumerator()

 

http://www.java2s.com/Tutorial/CSharp/0220__Data-Structure/Getitsenumeratorforanarray.htm

 

Following program is in the above website. I wish to know the function of

IEnumerator ie = intArray.GetEnumerator();.In other words what it does.

 

Please explain.

 

Thank you

 

 

using System;

using System.Collections;

 

class MainClass

{

   static void Main()

   {

      int[] intArray = { 10, 11, 12, 13 };

 

      IEnumerator ie = intArray.GetEnumerator();

 

      while (ie.MoveNext() == true)

      {

         int i = (int)ie.Current;

         Console.WriteLine("{0}", i);

      }

   }

}

/*

10

11

12

13

*/

Answers (2)