Suppose we have a string of words and we need to figure out how many of them have been repeated.The below code will help to do so
Imports System.Linq
Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim lstWords As String = "hello this is dotnet funda . dotnet funda is a dotnet forum"
(From g In From word In lstWords.Split(" "C)Group 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
Hope this will be helpful.