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.
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 .
0
Thank you, your answer made me think it from "new" angle and i managed to complete the task!