using System.Collections.Generic;
public Person(string name, string surname, DateTime birth)
public Person(): this ("UnknownName", "UnknownSurname", DateTime.Now)
_birth = new DateTime(value, _birth.Month, _birth.Day);
public override string ToString()
return String.Format("Имя: {0}\nФамилия: {1}\nДата рождения: {2}", _name, _surname, _birth.ToShortDateString());
public virtual string ToShortString()
return String.Format("Имя: {0}\nФамилия: {1}", _name, _surname);
private string _position;
public Employee(Person pers, string position, DateTime work)
public Employee(): this (default (Person), "UnknownPosition", DateTime.Now)
_work = new DateTime(value, _work.Month, _work.Day);
public override string ToString()
return String.Format("Работник {0}\n\n Должность: {1}\n Дата принятия на работу: {2}", _pers, _position, _work);
public virtual string ToShortString()
return String.Format("Работник {0}\n\n Должность: {1}", _pers, _position);
public class Organisation
public Organisation(string orgname, int regnum, Form form, Employee[] emp)
public Organisation(): this ("UnknownOrgName", Convert.ToInt32("0"), Form.Unknown, default (Employee[]))
public override string ToString()
return String.Format("Название организации: {0}\nРегистрационный номер: {1}\nПравовая форма: {2}\nРаботники: {3}", _orgname, _regnum, _form, _emp);
public virtual string ToShortString()
return String.Format("Название организации: {0}\nПравовая форма: {1}", _orgname, _form);
static void Main(string[] args)
Person pers1 = new Person();
Console.WriteLine("Экземпляр класса с полями, заполненными по умолчанию");
Console.WriteLine(pers1.ToString());
Console.WriteLine(pers1.ToShortString());
Console.WriteLine("Введите имя, фамилию, дату рождения через Enter");
pers2 = new Person(Console.ReadLine(), Console.ReadLine(), DateTime.Parse(Console.ReadLine()));
Console.WriteLine("Возникла следующая ошибка: {0}", ex.Message);
Console.WriteLine("\nРезультат заполнения:\n{0}", pers2.ToString());
Employee emp1 = new Employee();
emp1.Position = "Садовник";
emp1.Work = DateTime.Parse("23.12.1234");
Console.WriteLine(emp1.ToString());
Organisation org1 = new Organisation();
Console.WriteLine("Экземпляр класса с полями, заполненными по умолчанию");
Console.WriteLine(org1.ToString());
Console.WriteLine(org1.ToShortString());
org1.OrgName = "Васильки";
org1.RegNum = Convert.ToInt32("225695");
org1.FormForm = Form.ZAO;
Console.WriteLine("\nИзмененные свойства объекта org1:");
Console.WriteLine(org1.ToString());