Mega Code Archive

 
Categories / VB.Net / LINQ
 

Determine if the two lists are equal

Imports System Imports System.Linq Imports System.Collections.Generic     Class Pet         Public Name As String         Public Age As Integer     End Class Public Class Example     Public Shared Sub Main()          Dim pet1 As New Pet With {.Name = "Turbo", .Age = 2}         Dim pet2 As New Pet With {.Name = "Peanut", .Age = 8}         Dim pets1 As New List(Of Pet)()         pets1.Add(pet1)         pets1.Add(pet2)         Dim pets2 As New List(Of Pet)()         pets2.Add(New Pet With {.Name = "Turbo", .Age = 2})         pets2.Add(New Pet With {.Name = "Peanut", .Age = 8})                  Dim equal As Boolean = pets1.SequenceEqual(pets2)         Console.WriteLine(equal)     End Sub End Class