Mngaro Mwazenje

Mngaro Mwazenje

  • NA
  • 80
  • 12.2k

search for string in a list if found say "name" found if not

Feb 17 2020 2:15 AM
  1. public static void Main(string[] args)  
  2. {  
  3. List<string> list = new List<string>();  
  4. while (true)  
  5. {  
  6. string input = Console.ReadLine();  
  7. if (input == "")  
  8. {  
  9. break;  
  10. }  
  11. list.Add(input);  
  12. }  
  13. Console.WriteLine("Search for " );  
  14. string look = Convert.ToString(Console.ReadLine());  
  15. list.Contains(look);  
  16. Console.WriteLine("found " + look);  

Answers (5)