I have a text file :
20160906000001 // header with dateTime = 20160906 and code = 000001
name0100000152255 // body with name = name01 and reference = 00000152255
name0200000152256 // body with name = name02 and reference = 00000152256
name0300000152257 // body with name = name03 and reference = 00000152257
and class :
public class file
{
public header header { get; set; }
public List<body> body { get; set; }
}
public class header
{
public string dateTime { get; set; }
public string code { get; set; }
}
public class body
{
public string name { get; set; }
public string reference { get; set; }
}
I want to create a instance of my class file from the text file :
- property datetime in header have always 8 chars
- property code in header have always 6 chars
- property name in body have always 6 chars
- property reference in body have always 11 chars
What is the best way to do this?