static void Main(string[] args) { var trainings = new TrainingsCollection <Training>(); trainings.Add(new Training { Name = "C#", Cost = 10 }); trainings.Add(new Training() { Name = "Java", Cost = 10 }); // This loop with trigger to IEnumerator<T> GetEnumerator() from our custom TraningsEnumerator foreach (var item in trainings) { Console.WriteLine($"Traning Name {item.Name} and cost {item.Cost}"); } Console.ReadKey(); }
public TraningsEnumerator(TrainingsCollection <T> collection) { this.collection = collection; }