I am trying to parse a date into a list of objects with 2 strings from a text file. I have a string than Date and than another string in the text file on the same line.
Like the following
"Adam-15/02/2000-Likes pasta"
I tried doing the following to get the DateTime but i keep getting the error
String was not recognized as a valid DateTime.
My code
List<ChildDetails> children = new List<ChildDetails>();
string line;
System.IO.StreamReader file new System.IO.StreamReader(@"C:\Users\tomik\Desktop\School Y2 T2\Application Development\LAB3\\WindowsFormsApplication1\BodkinVanHorn.docx");
while ((line = file.ReadLine()) != null)
{
string[] words = line.Split('-');
children.Add(newChildDetails(words[0],DateTime.ParseExact(words[1],"dd/mm/yyyy", null), words[2]));
}