Grouping with Group By : Group « LINQ « VB.Net






Grouping with Group By

  

Imports System.IO
Imports System.Reflection
Imports System.Linq
Imports System.Xml.Linq

Public Class MainClass
   Public Shared Sub Main

        Dim numbers() As Integer = {5, 4, 1, 3, 10}

        Dim numberGroups = From num In numbers _
                           Group num By Remainder = num Mod 2 Into NumberGroup = Group _
                           Select Remainder, NumberGroup

        For Each g In numberGroups
            For Each n In g.NumberGroup
                Console.WriteLine(n)
            Next
        Next
   End Sub


End Class

   
    
  








Related examples in the same category

1.Using Group By to partition a list of projectList by category
2.Nested Group By
3.Alternative syntax for Grouping All
4.Grouped Average