Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- namespace Articulos.Cap04.Iteardores
- {
- public sealed class Multiplesyield
- {
- public static void Main()
- {
- Console.WriteLine ();
- // Consumidor del iterador:
- foreach (int numero in ListaNumeros())
- {
- Console.WriteLine ("{0} ", numero.ToString());
- }
- Console.ReadLine ();
- }
- // Método iterador con múltiples sentencias
- // yield return:
- private static IEnumerable ListaNumeros()
- {
- yield return 1;
- yield return 2;
- yield return 3;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement