0

How to full fill the condition of iteration in array using Contain method

C# Module Project Word, how do i print no match statement after iterating through array. I am using foreach loop, but it returning no match for every input case letter along with the word. TIA.

19th Apr 2021, 7:38 AM
Muhammad Hamza
Muhammad Hamza - avatar
2 Réponses
+ 1
Use a boolean variable initialized as false. While checking if you find the value, set it to true. After the loop, if boolean is false print no match
19th Apr 2021, 7:41 AM
Soumik
Soumik - avatar
0
Example in string method Contains using System; namespace SoloLearn { class Program { static void Main(string[] args) { string wordarr = "Hello World"; string findword = "World"; if (wordarr.Contains(findword)) Console.Write("Contains"); else Console.Write("No match"); } } }
19th Apr 2021, 8:32 AM
DUN
DUN - avatar