Загрузка данных


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    public class Program
    {
        public class MyArray : IEnumerable
        {
            public string[] people = { "Tom", "Sam", "Bob" };
            public IEnumerator GetEnumerator()
            {
                return new MyEnumerator(people);
            }
        }
        public class MyEnumerator : IEnumerator
        {
            public string[] ppl;
            int index = -1;
            public object Current { get { return ppl[index];  } }

            public MyEnumerator(string[] people) { ppl = people;  }
            public bool MoveNext()
            {
                index++;
                return index < ppl.Length;
            }

            public void Reset()
            {
                index = -1;
            }
        }
        static void Main(string[] args)
        {
            MyArray people = new MyArray();// { "Tom", "Sam", "Bob" };
            IEnumerator peopleEnumerator = people.GetEnumerator(); // получаем IEnumerator
            while (peopleEnumerator.MoveNext())   // пока не будет возвращено false
            {
                string item = (string)peopleEnumerator.Current; // получаем элемент на текущей позиции
                Console.WriteLine(item);
            }
            peopleEnumerator.Reset();
        }
    }
}