0

Whats problem my dear freand ??

I write This code for "Words project" in C# I dont know its errror: using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { string[] words = { "home", "programming", "victory", "C#", "football", "sport", "book", "learn", "dream", "fun" }; string letter = Console.ReadLine(); //your code goes here foreach (int count in words ) { If (count.Contains (letter)) { Console.WriteLine(count); } else { Console.WriteLine("No match"); } } } } }

28th Oct 2021, 7:04 PM
Xahin
Xahin - avatar
3 ответов
+ 6
Xahin , there are some issues in the code (for details see code file) https://code.sololearn.com/cEtUUInKtqy9/?ref=app
28th Oct 2021, 7:42 PM
Lothar
Lothar - avatar
+ 1
string[] words = { "home", "programming", "victory", "C#", "football", "sport", "book", "learn", "dream", "fun" }; string letter = Console.ReadLine(); string m = "No match"; foreach (string word in words ) if (word.Contains(letter)) { m = word; break; } Console.WriteLine(m); Note: Lothar code was excellent and displays all the words that contains the letters you put as the input in the program and my code displayed only the first word.
28th Oct 2021, 9:32 PM
SoloProg
SoloProg - avatar
+ 1
Xahin words is a collection of string so count can't be int
29th Oct 2021, 1:51 AM
A͢J
A͢J - avatar