Mega Code Archive

 
Categories / VB.Net / Data Structure
 

Enumerable Concat(TSource) concatenates two sequences

Imports System Imports System.Linq Imports System.Collections.Generic     Structure Pet         Public Name As String         Public Age As Integer     End Structure Public Class Example     Public Shared Sub Main()          Dim cats() As Pet = {New Pet With {.Name = "A", .Age = 8}, _                              New Pet With {.Name = "B", .Age = 4}, _                              New Pet With {.Name = "C", .Age = 1}}         Dim dogs() As Pet = {New Pet With {.Name = "D", .Age = 3}, _                              New Pet With {.Name = "E", .Age = 14}, _                              New Pet With {.Name = "F", .Age = 9}}         Dim query As IEnumerable(Of String) = cats .Select(Function(cat) cat.Name) .Concat(dogs.Select(Function(dog) dog.Name))                  For Each name As String In query             Console.WriteLine(name)         Next              End Sub End Class