Subscribe to our YouTube Channel for more Videos

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


Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.