What I would like to do is pick a line from a text file. That line number is corresponding with a local variable. So if the variable is 1, pick line one. The text file is in Resources and called nl_5.txt. After that the picked line (a word) should placed in a new array, but each letter should be placed at a new index. So if the variable is 1, line one is apple. Something like this:
string[] arr1 = new string[] { "a", "p", "p", "l", "e" }; (0=a 1=p 2=p 3=l 4=e)
If the local variable is changing to 2, line two should be read and the array should be changed with the other line (other word, other letters). How should I do this?
I found different variants like read the complete file or read specific lines who're defined, but I've tried a lot with no correct result.
int lineCount = File.ReadAllLines(@"C:\test.txt").Length;
int count = 0;
private void button1_Click(object sender, EventArgs e)
{
var reader = File.OpenText(@"C:\test.txt");
if (lineCount > count)
{
textBox1.Text = reader.ReadLine();
count++;
}
}