Как можно реализовать чтение данных из текстового файла? далее как создать массив персон?
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace Person
{
class Person
{
//свойства
public string LastName { get; }
public string Name { get; }
public string Patronymic { get; }
private bool Gender { get; } /* 0 - male, 1 - female */
public DateTime Birthday { get; }
public int Height { get; }
public int Weight { get; }
public int Age { get; }
//методы
public int Сalculate_age(DateTime Birtday)
{
var now = DateTime.Now;
return now.Year - Birthday.Year - (now.Month > Birthday.Month || now.Month == Birthday.Month && now.Day >= Birthday.Day ? 0 : 1);
}
public Person(string LastName, string Name, string Patronymic, bool Gender, DateTime Birthday, int Height, int Weight, int Age)
{
this.LastName = LastName;
this.Name = Name;
this.Patronymic = Patronymic;
this.Gender = Gender;
this.Birthday = Birthday;
this.Height = Height;
this.Weight = Weight;
this.Age = Age;
}
public static Person Parse(string text) // считываем информацию из файла
{
return 0;
}
public override string ToString()
{
}
}
class Program
{
static void Main(string[] args)
{
string path = "C:\\Users\\1392680\\source\\repos\\C#\\ООП_1\\1_work.txt";
string[] file = File.ReadAllLines(@path);
//Person person_1 = new Person(file[0], file[1], file[2],file[3], file[4], file[5], file[6], file[7]);
//public Person LastName = file[0];
}
}
}
Данные из файла:
Табаков
Валерий
Филиппович
0
19.11.2001
186
83
Шпак
Елена
Антоновна
1
25.06.1988
173
72
Левченко
Лев
Даниилович
0
07.08.2000
195
89
Каблукова
Людмила
Олеговна
1
27.01.1997
188
76
Илларионов
Тимофей
Сергеевич
0
25.06.2001
190
83