I'm reading all the lines from a text file into a list called 'masterToken', i'm trying to remove all the whitespace that will be in the list (all the spaces that were in the text file). masterToken = masterToken.Where(s => !string.IsNullOrWhiteSpace(s)).ToList(); is what i'm trying to use currently, it isn't working.
What is wrong with masterToken = masterToken.Where(s => !string.IsNullOrWhiteSpace(s)).ToList(); and/or is there a better way of achieving what I want?
Thanks
public static void Lex()
{        
  List<string> masterToken = File.ReadAllLines("C:\\Users\\Theo\\Documents\\Visual Studio 2017\\Projects\\Interpreter\\test.txt").ToList();
  foreach (var item in masterToken)
  {
    Console.Write(item.ToString());
  }
  masterToken = masterToken.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
  Console.WriteLine("");
  foreach (var item in masterToken)
  {
    Console.Write(item.ToString());
  }
  Console.ReadLine();
}
 
     
     
     
    