I have a .txt file that looks something like this:
1,Bob,Male //first row
2,Jim,Male //second row
3,Mary,Female //third row
I want to put these items into a generic list in c#, storing each column into something as "Id", "Name", "Gender" and treating each row as a different item of the list.
How would I go about doing this? I have no idea where to even start. I've looked at I/O operations and understand how to access a file, but I don't know how to create a variable name for each column and store each row as a new entry.
PersonPerson will have 3 properties
List<Person> listOfPerson = new List<Person>();
Person person = new Person();
stringwhich you create with splitting
p.ID = arrand so on
I answer you with text so you should try something by yourself and learn how to do it in the future !