Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace classes
- {
- class Student
- {
- public string FirstName { get; set; }
- public string LasttName { get; set; }
- public int Age { get; set; }
- public string Hometown { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split().ToArray();
- List<Student> list = new List<Student>();
- while (input[0] != "end")
- {
- string firstName = input[0];
- string lastName = input[1];
- int age = int.Parse(input[2]);
- string hometown = input[3];
- Student student = new Student();
- {
- student.FirstName = firstName;
- student.LasttName = lastName;
- student.Age = age;
- student.Hometown = hometown;
- }
- list.Add(student);
- input = Console.ReadLine().Split().ToArray();
- }
- string last = Console.ReadLine();
- List<Student> filtered = list.Where(x => x.Hometown == last).ToList();
- foreach (var student in filtered)
- {
- Console.WriteLine($"{student.FirstName} { student.LasttName} is { student.Age } years old.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement