Advertisement
IanosStefanCristian

Match / No match letter in a array of strings

Mar 17th, 2021
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Practice
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] words = { "life", "love", "money", "luck", "chess", "snake" };
  14. var count = 0;
  15. char letter = Convert.ToChar(Console.ReadLine());
  16. foreach(var i in words)
  17. {
  18. if (i.Contains(letter)) { Console.WriteLine(i); }
  19. else { count++; }
  20. }
  21. if (count == words.Length) { Console.WriteLine("No match"); }
  22. Console.ReadLine();
  23. }
  24. }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement