Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.