+ 1

TXT files to Array

Suppose I have this list in the TXT file 0 Valdivia Corina Y 1 Longoria Julia N In the C#, I have the following: ID[10] (as an integer) lastName[10] (as a string) firstName[10] (as a string) workingToday[10] (as a character) What codes do I use to transfer ID, lastName, firstName, workingToday from the .txt file to the arrays?

19th May 2018, 7:49 PM
Luis Cerrillo
Luis Cerrillo - avatar
2 Answers
+ 1
What I do is read the file line by line then split up each line. using the split function. Here a link to get you started with files in C# http://www.csharp-examples.net/read-text-file/
19th May 2018, 9:24 PM
Ben
Ben - avatar
0
To read the text from the file use string[] readText = File.ReadAllLines(path); use a foreach loop to loop through all lines use s.split(' ') to seperated all parts of the a line in elements that can be assigned to variables Have a look at my code https://code.sololearn.com/caMddY7grnY8
19th May 2018, 10:17 PM
sneeze
sneeze - avatar