I am reading in a csv file that I would like to add the second column into the same list as a column that match the name. I check the the next line is equal to the previous record but then I loop the array finding the match but I am not sure how to add that internalList back into the class object.
is there a better way to do this?
Program
while ((s = sr.ReadLine()) != null)
{
string[] words = s.Split('\t');
if (previousrecord == words[0])
{
for (int i = 0; i < ALEComName.Count; ++i)
{
}
}
else
{
Name person = new Name();
person.Name = words[0];
List<SubName> internalList = new List<SubName>();
SubName AssociatedSub = new SubName { Name = words[1] };
internalList.Add(AssociatedSub);
person.AssociatedSub = internalList;
ALEComName.Add(Disease);
}
previousrecord = words[0];
Dto
public class Name
{
public string Name { get; set; }
public List<SubName> AssociatedSub { get; set; }
}
public class SubName
{
public string Name { get; set; }
}
}
CSV File
A A
B B
C A
C B
C C
D A
D B