Partition following list of numbers by their remainder when divided by “3”-{Var numbers() = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}}
(Vb)
Public Sub PartitioningExample()
Dim numbers() = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0}
Dim numberGroups = From n In numbers Group n By key = n Mod 3 Into Group _
Select Remainder = key, NumberGroup = Group
For Each g In numberGroups
Console.WriteLine("Numbers with a remainder of {0} when divided by 3:", g.Remainder)
For Each n In g.NumberGroup
Console.WriteLine(n)
Next
Next
End Sub