Below is a sample code snippet that demonstrates the usage of the GetEnumerator , and MoveNext to iterate through a list of integers in C#.
Iterating a List of Integer using GetEnumerator , MoveNext and Current in C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ACSample { class Program { static void Main(string[] args) { // Iterating a List of Integer using GetEnumerator , MoveNext and Current in C# List<int> ACInput = new List<int> { 1, 2, 3, 4, 5, 6 }; List<int>.Enumerator e = ACInput.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current); } } }
1 Comment