using System;
using System.Collections;
namespace Iterator_test
{
class Day
{
int days_idx = -1;
private String[] days = { "mon", "tue", "wed","thu","fri","sat","sun" };
public IEnumerable getdays()
{
days_idx++;
yield return days[days_idx];
}
}
class Program
{
static void Main(string[] args)
{
Day d = new Day();
foreach (string day in d.getdays())
{
Console.WriteLine(day);
}
}
}
}
Actually the output should be,
mon
tue
wed
thu
fri
sat
sun
but its printing only "mon" as,
mon
What will be the reason?