0

How to fix these?

static void Main(string[] args) { string[] words = { "home", "programming", "victory", "C#", "football", "sport", "book", "learn", "dream", "fun" }; string letter = Console.ReadLine(); int count = 0; //your code goes here for(; count=words.Index; count++) { if words.Contains("letter")=words[count] Console.WriteLine(words[count]); } } } }

28th Aug 2022, 6:30 PM
TheMasterBee
TheMasterBee - avatar
1 Antwort
0
TheMasterBee What is word.index? "letter" is a String and letter is a variable so there should be words.Contains(letter) Single equal is used to assign value not compare value. Don't compare just increase count if words contains letter And outside the loop check if count is 0 then print "No match" solution would be like this: for (string word in words) { if (word.Contains(letter) { count++; } } if (count == 0) { print ('No match'); }
29th Aug 2022, 10:02 AM
A͢J
A͢J - avatar