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);
- Console.WriteLine("кого искать?");
- string name = Console.ReadLine();
- Student x = StudentsBase.Search(firstname);
- Console.WriteLine(x.Firstname);
- }
- }
- class Journal
- {
- private 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 searchfirstname)
- {
- Student stud = null;
- foreach (Student i in students)
- {
- if (i.Firstname == searchfirstname)
- return stud = i;
- else
- Console.WriteLine("Поиск не дал результата.");
- }
- return stud;
- }
- }
- public class Student
- {
- public string Firstname;
- public string Lastname;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement