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 *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...