Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Students
- {
- public class StartUp
- {
- public static void main(string[] args)
- {
- }
- }
- class Student
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public int Age { get; set; }
- public string City { get; set; }
- public static void Main()
- {
- List<Student> students = new List<Student>();
- string line = Console.ReadLine();
- while (line != "end")
- {
- string[] token = line.Split();
- string firstname = token[0];
- string lastName = token[1];
- int age = int.Parse(token[2]);
- string city = token[3];
- Student student = new Student()
- {
- FirstName = firstname,
- LastName = lastName,
- Age = age,
- City = city
- };
- students.Add(student);
- line = Console.ReadLine();
- }
- string filterCity = Console.ReadLine();
- foreach (Student student in students)
- {
- if (student.City == filterCity)
- {
- Console.WriteLine($"{student.FirstName} {student.LastName} is {student.Age} years old.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement