Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Numerics;
- namespace fundamental14
- {
- class Student
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public int Age { get; set; }
- public string City { get; set; }
- }
- class MainClass
- {
- public static void Main()
- {
- string input;
- List<Student> students = new List<Student>();
- while ((input = Console.ReadLine()) != "end")
- {
- string[] array = input.Split();
- string firstName = array[0];
- string listName = array[1];
- int age = int.Parse(array[2]);
- string city = array[3];
- Student student = new Student();
- student.FirstName = firstName;
- student.LastName = listName;
- student.Age = age;
- student.City = city;
- students.Add(student);
- }
- string outputCity = Console.ReadLine();
- List<Student> newListStudent = students.Where(x => x.City == outputCity).ToList();
- foreach (Student studentOut in newListStudent)
- {
- Console.WriteLine($"{studentOut.FirstName} {studentOut.LastName} is {studentOut.Age} years old.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement