public List <string> StartingWith(string file, string letter) { sReader = new StreamReader(file); txtReturn = sReader.ReadToEnd().Split(',', ' '); foreach (string toAddList in txtReturn) { WordList.Add(toAddList); } foreach (string filteredData in WordList) { if (filteredData.ToUpper().StartsWith(letter.ToUpper())) { WordListReturn.Add(filteredData); } } sReader.Close(); return(WordListReturn); }
public List <string> GetAllWordsClean(string file) { while (string.IsNullOrEmpty(file)) { Console.WriteLine("Por favor, insira o caminho do txt com as palavras separadas por virgula (,). Obrigado!"); file = Console.ReadLine(); } sReader = new StreamReader(file); txtReturn = sReader.ReadToEnd().Split(',', ' '); foreach (string toAddList in CleaningList(txtReturn.ToList())) { WordList.Add(toAddList); } foreach (string filteredData in WordList) { WordListReturn.Add(filteredData); } sReader.Close(); return(WordListReturn); }