private static void EnumerableExample() { Console.WriteLine(); Console.WriteLine("-----------------------------Enumerable Example-----------------------------"); //Enumerating example var bands = new BandsEnumerable(BandsArray); var enumerator = bands.GetEnumerator(); while (enumerator.MoveNext()) { var band = enumerator.Current; Console.WriteLine("{0} ({1}, {2}): {3} albums.", band.Name, band.Genre, band.Country, band.StudioAlbums); } Console.WriteLine(); //TODO 1: Change "BandsEnumerator" to enumerate from last element to first. var bandsReverse = new BandsEnumerableReverse(BandsArray); var enumeratorReverse = bandsReverse.GetEnumerator(); while (enumeratorReverse.MoveNext()) { var band = enumeratorReverse.Current; Console.WriteLine("{0} ({1}, {2}): {3} albums.", band.Name, band.Genre, band.Country, band.StudioAlbums); } Console.WriteLine(); Console.WriteLine("Collections - Extra (for home) 1.Add an indexer to the BandsEnumerable class and print the items using the index."); //Collections - Extra (for home) 1.Add an indexer to the BandsEnumerable class and print the items using the index. for (var i = 0; i < bandsReverse.Count(); i++) { Console.WriteLine("{0} ({1}, {2}): {3} albums.", bandsReverse[i].Name, bandsReverse[i].Genre, bandsReverse[i].Country, bandsReverse[i].StudioAlbums); } }
private static void EnumerableExample() { Console.WriteLine(); Console.WriteLine("-----------------------------Enumerable Example-----------------------------"); //Enumerating example var bands = new BandsEnumerable(BandsArray); var enumerator = bands.GetEnumerator(); while (enumerator.MoveNext()) { var band = enumerator.Current; Console.WriteLine("{0} ({1}, {2}): {3} albums.", band.Name, band.Genre, band.Country, band.StudioAlbums); } //TODO 1: Change "BandsEnumerator" to enumerate from last element to first. }
private static void EnumerableExample() { Console.WriteLine(); Console.WriteLine("=====Example 1 (Enumerable example)====="); //Enumerating example var bands = new BandsEnumerable(BandsArray); var enumerator = bands.GetEnumerator(); while (enumerator.MoveNext()) { var band = enumerator.Current; Console.WriteLine($"{band.Name} ({band.Genre}, {band.Country}): {band.StudioAlbums} albums."); } //TODO 1: Change "BandsEnumerator" to enumerate from last element to first. }