I'm trying to create an application that confronts a string given in input by the user to a series of words written in the file. Each word is written on a different line without spaces between the lines. They look like this:
TEST
WORD
TEST2
And I would need the array to save them each with their own position so that if I used array[1] , I would get "WORD".
I have tried a few different methods but I can't make it work. Now I am trying to use the File.ReadLines command this way:
string[] wordlist;
string file = @"C:\file";
bool check = false;
if(File.Exists(file))
{
wordlist = File.ReadLines(file).ToArray();
}
for(int i = 0; i < wordlist.Length && check == false; i++)
{
if(wordInput == wordlist[i])
check = true;
}
I don't understand if this turns the entire file into one big variable or if it just saves the lines not as strings but as something else