Как создать конструктор для структуры со структурой? - C#
Формулировка задачи:
Листинг программы
- struct Student
- {
- string name,lastName;
- struct Date
- {
- int year;
- int month;
- int day;
- }
- string interest;
- public Student(string name,string lastName,string interest, int year,int month,int date)
- {
- this.name = name;
- this.lastName = lastName;
- this.interest = interest;
- //this.Date.year = year;
- //this.Date.month = month;
- //this.Date.date = date;
- }
Решение задачи: «Как создать конструктор для структуры со структурой?»
textual
Листинг программы
- struct Student
- {
- string name,lastName;
- string interest;
- Date date;
- public Student(string name,string lastName,string interest, int year,int month,int day)
- {
- this.name = name;
- this.lastName = lastName;
- this.interest = interest;
- date = new Date(year, month, day);
- }
- }
- struct Date
- {
- int year;
- int month;
- int day;
- public Date(int year, int month, int day)
- {
- this.year = year; this.month = month; this.day = day;
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д