0

Help C# tutorial arrays final task "Words"

I need help with "Words", my code looks like this for(count=0; count<words.Length; count++) if(words[count].Contains(letter)) { Console.WriteLine(words[count]); } When i use if statement for "No match" it shows every iteration like it should but i have no clue how to show just once "No match", if there is no words which has the user input letter.

31st Jan 2021, 9:46 AM
Miika Viinikainen
Miika Viinikainen - avatar
2 ответов
+ 2
First take some variable and set it to true and instead of using "no match" ,set the variable value to false . Then at the end of for loop check , if (!(variable)){ Console.WriteLine("no match"); } or if it's possible you could just break the loop with the way you are were doing .
31st Jan 2021, 10:02 AM
Abhay
Abhay - avatar
0
Thank you, your answer made me think it from "new" angle and i managed to complete the task!
1st Feb 2021, 9:46 PM
Miika Viinikainen
Miika Viinikainen - avatar