0
A little help with strings in c#
i can only print the numbers of characters and i was wondering how can i print words that start with a specific letter ? i want to print the words hi and how. string str = "hi how are you?"; int count = 0; foreach(char letter in str) { if (letter == 'h') { count++; } } Console.WriteLine("the number of characters of h is:{0}", count); Console.ReadLine();
1 Answer
+ 5
split with space,
loop over the array,
if the first character is h,
print the item