- Visual Studio 2008 (Beta2 or Higher)
Categories: LINQ-To-Objects, LINQ and WinForms
Instructions:
CheckedListBox1.Items.AddRange( _
New String() {"Apple", "Orange", "Banana", _
"Avocado", "Tomato", "Tamarillo", _
"Kiwifruit", "Cherry"})
MsgBox( _
Aggregate Box In CheckedListBox1.CheckedItems _
Into Concat())
Public Module AggregateModule
<Extension()> Public Function Concat(Of Type)( _
ByVal ie As IEnumerable(Of Type)) As String
Dim str As String = ""
For Each item In ie
If str <> "" Then str &= ","
str &= item.ToString()
Next
Return str
End Function
End Module
MsgBox((From c In _
CheckedListBox1.CheckedItems).Aggregate( _
Function(ByVal x, ByVal y) x + "," + y))