How to get an Enumerator from range of elements from ArrayList in C# ?

The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of elements of ArrayList ion C#.

How to get an Enumerator from range of elements from ArrayList in C# ?

using System;
using System.Collections;

namespace ACConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList websites = new ArrayList(5);
           
            websites.Add("Ginktage.com");
            websites.Add("TechBlog Ginktage.com");
            
            // Get the enumerator
            IEnumerator enumerator = websites.GetEnumerator();
            // Get the elements from the enumerator.
            while(enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }
           
            Console.ReadLine();
        }
    }
}


Leave a Reply

Your email address will not be published. Required fields are marked *