static void Main(string[] args) { ListOfEmployee <Employer> listOfEmployee1 = new ListOfEmployee <Employer>(); listOfEmployee1.Add(new Employer("Ваня Иванов", new DateTime(1992, 03, 20))); listOfEmployee1.Add(new Employer("Петя Петров", new DateTime(1995, 03, 23))); listOfEmployee1.Add(new Employer("Коля Новогодний", new DateTime(1991, 04, 01))); listOfEmployee1.Add(new Employer("Стас Рождественский", new DateTime(1998, 04, 07))); listOfEmployee1.Add(new Employer("Антон Павлович", new DateTime(1986, 05, 03))); listOfEmployee1.Add(new Employer("Денис Какойто", new DateTime(1990, 05, 25))); Console.WriteLine(listOfEmployee1.ToString(2, listOfEmployee1)); }
// public DateTime nextMonth = DateTime.Today.AddMonths(1); // public DateTime nextMonth2 = DateTime.Today.AddMonths(2); public string ToString(int monghtLenght, ListOfEmployee <Employer> list) { string result = ""; for (int i = 0; i <= monghtLenght; i++) { result += $"{today.AddMonths(i).ToString("MMMM yyyy")}\n"; foreach (Employer employer in list) { if (employer.birthDay.Month == today.AddMonths(i).Month) { result += $"({employer.birthDay.ToString("dd")}) - {employer.name} ({employer.age} лет)\n"; } } } return(result); }