Class Practice

 avatar
unknown
csharp
a year ago
2.1 kB
4
Indexable
#region THEORY
//// Предметы
//// Огурец
//// Помидор
//// Лимон
//// Клубника

//string cucumberName = "Огурец";
//string cucumberType = "Овощь";

//string tomatoName = "Помидор";
//string tomatoType = "Овощь";

//string lemonName = "Лимон";
//string lemonType = "Фрукт";

//string strawberryName = "Клубника";
//string strawberryType = "Ягода";

//string[] items = new string[] { cucumberName, cucumberType };

//Item cucumber = new Item() { Name = "Огурец", Type = "Овощь" };

//cucumber.Name = "Огурец 2";
//cucumber.Type = "Овощь 2";

//Item tomato = new Item("Помидор");

//Console.WriteLine(tomato.Name);

//class Item
//{
//    public string Name;
//    public string Type;

//    public Item()
//    {
//        Console.WriteLine("Обьект создан");
//    }

//    public Item(string name)
//    {
//        Name = name;
//    }
//} 
#endregion

Console.WriteLine("1. Добавить студента");

Console.ReadLine();

Student testStudent = new Student(
    "TestFN",
    "TestLN",
    "test@gmail.com",
    "testLocation",
    "7775275298");

Student newStudent = new Student();

Console.WriteLine("Введите имя:");
newStudent.FirstName = Console.ReadLine();
Console.WriteLine("Введите фамилию:");
newStudent.LastName = Console.ReadLine();

Student[] students = new Student[] { testStudent, newStudent };

foreach (Student student in students)
{
    Console.WriteLine(student.FirstName);
}

class Student
{
    public string FirstName;
    public string LastName;
    public string Email;
    public string Location;
    public string PhoneNumber;

    public Student()
    {

    }

    public Student(
        string firstName,
        string lastName,
        string email,
        string location,
        string phoneNumber)
    {
        FirstName = firstName;
        LastName = lastName;
        Email = email;
        Location = location;
        PhoneNumber = phoneNumber;
    }
}
Editor is loading...
Leave a Comment