Imports System.Collections.Generic
Imports System.Linq
Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())
'Question #4: Find how many times a word repeated in a given string.
Dim lstWords As New List(Of String)() From { _
"hello", _
"this", _
"is", _
"dotnet", _
"dotnet", _
"funda", _
"is", _
"is" _
}
(From g In From word In lstWordsGroup word By wordNew With { _
Key .Words = g.Key, _
Key .WordsRepeated = If((g.Count() - 1) = 0, [String].Concat("Word ", g.Key, " has never repeated"), [String].Concat("Word ", g.Key, " repeated ", g.Count(), " times")) _
}).ToList().ForEach(Function(i) Console.WriteLine("{0} : {1}", i.Words, i.WordsRepeated))
Console.ReadKey(True)
End Sub
End Class
End Namespace
/*Result
hello : Word hello has never repeated
this : Word this has never repeated
is : Word is repeated 3 times
dotnet : Word dotnet repeated 2 times
funda : Word funda has never repeated*/