What is Enumerables ? (part 2)

Taşkın Binbir
Jan 23, 2022


Hello folks,

I gonna show a few features on an example in this article with .net core 6 console.

var array = new int[] { 1, 2, 3 };foreach(var a in array){
Console.WriteLine($”Value is {a}”);
}var enumerator = array.GetEnumerator();while (enumerator.MoveNext()){
Console.WriteLine($”Enumerator value is {enumerator.Current}”);

In the above example, We have a array and we make the array enumerable with GetEnumerator() function. We use MoveNext() to get next value and we print next value with “Current” keyword.

Good luck.

previous post: https://taskinbinbir.medium.com/what-is-enumeration-f7b09c579728



Taşkın Binbir

Computer Engineer, Software Developer