I am trying to read the last line of a text file into an array so that I am able to get a specific element of the array by index, but I am having trouble doing this as 1 line in my text file has many elements that need to go into the array as opposed to there being 1 element per line, so for reference my text file line structure would be like so: element1,element2,element3... It is similar in structure to that of a csv file.
My code so far that is not working:
string lastline = System.IO.File.ReadLines(myfilepath).Last();
string[] id = new string[](lastline.Split(','));
Then after inserting the line to my array I would like to pull an element of the array by the index, for example I want to pull element2 from the array and assign it to var item2, but am not sure how to go about that.
id[index]does not do the job, I have not understood what you want.