Hey all. At the moment i'm struggling to read a file which contains 4 integers on each line separated by commas. I want to read each line then put them in a list like
Text File will look like
1, 3, 7, 9
2, 5, 6, 8
I want it to be put in a list. Basically so that in the list it contains 1 3 7 and 9, the next part of the list contains 2 5 6 and 8 etc.
The code i have for it is
public class NewList
{
public int ID { get; set; }
public int N1 { get; set; }
public int N2 { get; set; }
public int N3 { get; set; }
public NewList(int pID, int pN1, int pN2, int pN3)
{
this.ID = pID;
this.N1 = pN1;
this.N2 = pN2;
this.N3 = pN3;
}
Console.WriteLine("");
FileStream aFile = new FileStream("SomeData.txt", FileMode.Open);
List<NewList> Numbers = new List<>(NewList);
//In the Main()
using(StreamReader sr = new StreamReader(aFile))
{
while((strLine = sr.ReadLine()) != null)
{
Numbers.Add(strLine);
}
}
I know i need to involve Split somewhere as well