Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp14
- // номер три(список чего то там)
- {
- class Student_Test
- {
- public string Name;//имя
- public string Surname;//фамилия
- public int test_mark;//оценка
- public Student_Test(string name, string surname, int Test_Mark)//конструктор
- {
- Name = name;
- Surname = surname;
- test_mark = Test_Mark;
- }
- }
- class Program
- {
- public static void List_Add(List<Student_Test> list)
- {
- string name, surname;
- int mark;
- Console.Write("Enter student's name:");
- name = Console.ReadLine();
- Console.Write("Enter student's surname:");
- surname = Console.ReadLine();
- Console.Write("Enter student's test mark:");
- mark = Convert.ToInt32(Console.Read());
- Student_Test student = new Student_Test(name, surname, mark);
- list.Add(student);
- Console.WriteLine("Student added sucessfuly");
- }
- public static void List_Print(List<Student_Test> list)
- {
- int counter = 1;
- foreach (Student_Test student in list)
- {
- Console.WriteLine($"{counter}) Name:{student.Name} Surname:{student.Surname} Mark:{student.test_mark} ");
- counter++;
- }
- if (counter == 1)
- {
- Console.WriteLine("Your list is empty");
- }
- Console.ReadLine();
- }
- static void Main(string[] args)
- {
- List<Student_Test> myFirstList = new List<Student_Test>();
- while (true)
- {
- Console.WriteLine("Введите 1 если хотите добавить студента в список (введите 2 для вывода списка ): ");
- int x = Convert.ToInt32(Console.ReadLine());
- switch (x)
- {
- case 1:
- List_Add(myFirstList);
- break;
- case 2:
- List_Print(myFirstList);
- break;
- default:
- {
- Console.WriteLine("Некорректный ввод(");
- break;
- }
- }
- x = 0;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment