Enumerable.All tells whether all elements of a sequence satisfy a condition.
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 pets() As Pet = _
{New Pet With {.Name = "A", .Age = 2}, _
New Pet With {.Name = "B", .Age = 4}, _
New Pet With {.Name = "C", .Age = 7}}
Dim allNames As Boolean = pets.All(Function(ByVal pet) pet.Name.StartsWith("B"))
Console.WriteLine(allNames)
End Sub
End Class
Related examples in the same category