Question about Linq?

  • Thread starter Thread starter AU Gridlock
  • Start date Start date
A

AU Gridlock

Guest
Hi, This is my first time coming to LinQ
I have read this code and I have not understood the Order by Length statement
Where is the length from? Why does the code understand it?
Thanks so much, here is vb code

Dim sentence = "the quick brown fox jumps over the lazy dog"
' Split the string into individual words to create a collection.
Dim words = sentence.Split(" "c)

Dim query = From word In words
Group word.ToUpper() By word.Length Into gr = Group
Order By length
Select length, GroupedWords = gr

Dim output As New System.Text.StringBuilder
For Each obj In query
output.AppendLine(String.Format("Words of length {0}:", obj.Length))
For Each word As String In obj.GroupedWords
output.AppendLine(word)
Next
Next

Continue reading...
 
Back
Top