Hi,
This is the same as the previous answers, but it uses another way of using a for-loop:
List<string> years = new List<string>();
for (DateTime date = DateTime.Now.AddYears(-1); date <= DateTime.Now.AddYears(2); date = date.AddYears(1))
{
years.Add(date.Year.ToString("yyyy"));
}
I found out that date-loops (also day- / month- / hour- / minute- loops) are possible this way and I just wanted to share this ;)
Hope this helps someone.
Best regards and happy coding,
Stops