Hello! There was a problem changing the format of the variable. I have a class:
public class Parsing { public string FIO { get; set; } public DateTime Date { get; set; } } And the code itself:
string line; StreamReader file = new StreamReader(@"Путь"); List<Parsing> csv = new List<Parsing>(); while ((line = file.ReadLine()) != null) { var csvRow = line.Split(';').Skip(1).ToList(); var objList = new Parsing { FIO = (csvRow[0]), Date = DateTime.Parse(csvRow[1]), }; csv.Add(objList); } When I try to change the "Date" field to a date format, I get an error: "This string is not recognized as a valid DateTime value. An unknown word has been detected starting with index 0." I understand that this is due to the fact that my header is of type string, and the fields are already in Datetime format, but how can I get around this, I thought .Skip (1) will help me?
Вот пример CSV-файла: Дата рождения 12.12.1912 01.01.1901
whilecallfile.ReadLine()once to skip the header. - Alexander PetrovDateTime.ParseExact) - or passCultureInfo. - Pavel Mayorov