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;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnM7CgpuYW1lc3BhY2UgQXJ0aWN1bG9zLkNhcDA0Lkl0ZWFyZG9yZXMKewogICAgcHVibGljIHNlYWxlZCBjbGFzcyBNdWx0aXBsZXN5aWVsZAogICAgewogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKICAgICAgICB7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgpOwogICAgICAgICAgICAKICAgICAgICAgICAgLy8gQ29uc3VtaWRvciBkZWwgaXRlcmFkb3I6CiAgICAgICAgICAgIGZvcmVhY2ggKGludCBudW1lcm8gaW4gTGlzdGFOdW1lcm9zKCkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgiezB9ICIsIG51bWVyby5Ub1N0cmluZygpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICAgICAgQ29uc29sZS5SZWFkTGluZSAoKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgLy8gTcOpdG9kbyBpdGVyYWRvciBjb24gbcO6bHRpcGxlcyBzZW50ZW5jaWFzIAogICAgICAgIC8vIHlpZWxkIHJldHVybjoKICAgICAgICBwcml2YXRlIHN0YXRpYyBJRW51bWVyYWJsZSBMaXN0YU51bWVyb3MoKQogICAgICAgIHsKICAgICAgICAgICAgeWllbGQgcmV0dXJuIDE7CiAgICAgICAgICAgIHlpZWxkIHJldHVybiAyOwogICAgICAgICAgICB5aWVsZCByZXR1cm4gMzsKICAgICAgICB9CiAgICB9Cn0=