Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created August 18, 2014 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/29ac624ba0f4b2d75149 to your computer and use it in GitHub Desktop.
Save Fhernd/29ac624ba0f4b2d75149 to your computer and use it in GitHub Desktop.
Demostración de múltiples yield return en un método iterador.
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