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

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

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...