C# Practice
unknown
csharp
2 years ago
2.3 kB
26
Indexable
Student testStudent0 = new Student() { FirstName = "TestName0", Email = "TestEmail0" };
Student testStudent1 = new Student("TestName1", "TestLastName1");
Student testStudent2 = new Student("TestName2", "TestLastName2", "test2@gmail.com");
Student testStudent3 = new Student("TestName3", "TestLastName3", "test3@gmail.com", "Test3Address");
Student testStudent4 = new Student("TestName4", "TestLastName4", "test4@gmail.com", "Test4Address", 7771234578);
Student[] students = new Student[]
{
testStudent0,
testStudent1,
testStudent2,
testStudent3,
testStudent4,
new Student("FN", "LN")
};
Console.WriteLine("Меню");
Console.WriteLine("1. Показать всех студентов");
Console.WriteLine("2. Найти студента по имени");
Console.WriteLine("3. Добавить нового студента");
switch (Convert.ToInt32(Console.ReadLine()))
{
case 1:
foreach (Student student in students)
{
Console.WriteLine("=====================");
Console.WriteLine(student.FirstName);
Console.WriteLine(student.LastName);
Console.WriteLine(student.Email);
Console.WriteLine(student.Address);
Console.WriteLine(student.PhoneNumber);
Console.WriteLine("=====================");
}
break;
default:
break;
}
class Student
{
public string FirstName = "Неизвестное имя";
public string LastName = "Неизвестная фамилия";
public string Email = "Неизвестная эл. почта";
public string Address = "Неизвестный адресс";
public long PhoneNumber;
public Student()
{
}
public Student(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
public Student(string firstName, string lastName, string email)
{
FirstName = firstName;
LastName = lastName;
Email = email;
}
public Student(string firstName, string lastName, string email, string address)
{
FirstName = firstName;
LastName = lastName;
Email = email;
Address = address;
}
public Student(string firstName, string lastName, string email, string address, long phoneNumber)
{
FirstName = firstName;
LastName = lastName;
Email = email;
Address = address;
PhoneNumber = phoneNumber;
}
}Editor is loading...
Leave a Comment