using System.Collections.Generic;
public static void Main()
DateOnly birthDate = DateOnly.MinValue;
while (birthDate == DateOnly.MinValue)
Console.Write("Enter your birth date(yyyy-MM-dd)");
if (!DateOnly.TryParse(Console.ReadLine(), out birthDate))
Console.WriteLine("Invalid date");
Console.WriteLine($"You were born on {birthDate:dddd dd MMMM yyyy}\n");
Console.WriteLine($"Your birthday will be {birthDate:dddd} too in the following years:");
Enumerable.Range(birthDate.Year + 1, 100)
.Select(y=> new DateOnly(y,birthDate.Month,birthDate.Day))
.Where(d=>d.DayOfWeek == birthDate.DayOfWeek)
Console.WriteLine($"\t{d.Year} ({d.Year - birthDate.Year, 2:G} years old)");
public static class EnumerableExtension
public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
foreach(T item in enumeration)