Created
August 18, 2014 16:41
-
-
Save Fhernd/29ac624ba0f4b2d75149 to your computer and use it in GitHub Desktop.
Demostración de múltiples yield return en un método iterador.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment