Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication32
- {
- public class Program
- {
- static void Main(string[] args)
- {
- Journal studentsBase = new Journal();
- Console.WriteLine("Введите имя студента: ");
- string firstname = Console.ReadLine();
- Console.WriteLine("Введите фамилию: ");
- string lastname = Console.ReadLine();
- studentsBase.Addstudent(firstname, lastname);
- Student x = studentsBase.Search(firstname, lastname);
- Console.WriteLine(x);
- }
- }
- class Journal
- {
- public List<Student> students = new List<Student>();
- public void Addstudent(string studentFname, string studentLname)
- {
- Student student = new Student();
- student.firstname = studentFname;
- student.lastname = studentLname;
- students.Add(student);
- }
- public Student Search(string firstname, string lastname)
- {
- Student stud;
- stud = new Student();
- foreach (Student i in students)
- {
- if (i.firstname == firstname || i.lastname == lastname)
- {
- stud = i;
- Console.WriteLine(stud);
- }
- else
- Console.WriteLine("Поиск не дал результата.");
- }
- return stud;
- }
- }
- public class Student
- {
- public string firstname;
- public string lastname;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement