Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,943 questions

51,883 answers

573 users

How to use Array.GetEnumerator() method to get an IEnumerator for an Array in C#

1 Answer

0 votes
using System;
using System.Collections;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = { "PHP", "C", "C++", "C#", "Java", "JavaScript",
                           "VB.NET", "VB6", "Pascal", "Objective-C", "Python" };

            int i = 0;
            IEnumerator sEnumerator = s.GetEnumerator();

            while ((sEnumerator.MoveNext()) && (sEnumerator.Current != null))
                Console.WriteLine("s[{0}] = {1}", i++, sEnumerator.Current);
        }
    }
}


/*
run:
 
s[0] = PHP
s[1] = C
s[2] = C++
s[3] = C#
s[4] = Java
s[5] = JavaScript
s[6] = VB.NET
s[7] = VB6
s[8] = Pascal
s[9] = Objective-C
s[10] = Python

*/

 



answered Apr 23, 2016 by avibootz
...