From b8010176e1f24b0ff863e9f168f2715ad44e22fb Mon Sep 17 00:00:00 2001 From: Stanislav Mykhailenko Date: Sun, 19 Mar 2023 13:09:58 +0200 Subject: [PATCH] Update Lesson 2 Task 2 --- Lesson_2/Task_2/Program.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Lesson_2/Task_2/Program.cs b/Lesson_2/Task_2/Program.cs index 9bd749b..bb37e70 100644 --- a/Lesson_2/Task_2/Program.cs +++ b/Lesson_2/Task_2/Program.cs @@ -13,24 +13,21 @@ List people = new List() new Person("Alex",80) }; -string? userInput; - int minimum; int maximum; do { Console.Write("Enter minimum age: "); - userInput = Console.ReadLine(); -} while (!int.TryParse(userInput, out minimum) || minimum < 0 || minimum > 130); +} while (!int.TryParse(Console.ReadLine(), out minimum) || minimum < 0 || minimum > 130); do { Console.Write("Enter maximum age: "); userInput = Console.ReadLine(); -} while (!int.TryParse(userInput, out maximum) || maximum < minimum || maximum > 130); +} while (!int.TryParse(Console.ReadLine(), out maximum) || maximum < minimum || maximum > 130); -var selected = from s in people where s.Age >= minimum && s.Age <= maximum select s; +var selected = from person in people where person.Age >= minimum && person.Age <= maximum select person; foreach (Person person in selected) {