Im making a basic CSV Reader. Im sepparating the header from the contents using header and data.
Now, my lists contain data of the type person.:
public class person
{
public int id;
public string name;
public int age;
public person(string id, string name, string age)
{
try
{
this.id = Convert.ToInt32(id);
this.name = name;
this.age = Convert.ToInt32(age);
}
catch (FormatException e)
{
Console.WriteLine(e.Message);
}
}
public string ToString()
{
return $"{id}, {name}, {age}";
}
}
Now id like to take the type data and make a type person that stores the information. Right now i am trying to use IEnumerable<> for everything since many comments here say that its better for memory management. Now, since it behaves a little different then List<T> I'm having issue making a type that stores persons. Im having errors left and right using IEnumerable so i couldnt be bothered to write my shitty code down.
var data = file.Skip(1).Select(p => p.Split(';'));
IEnumerable<person> listofperson;
My question is, how can i make this work using IEnumerable<>? Or should i even care and rather go for List<>?
ICollection<T>?