Mega Code Archive

 
Categories / VB.Net Tutorial / LINQ
 

Using Quantifiers All to determine whether an array contains only odd numbers

Imports System.IO Imports System.Reflection Imports System.Linq Imports System.Xml.Linq Public Class MainClass    Public Shared Sub Main         Dim numbers() As Integer = {1, 2, 3, 4, 5, 6, 7}         Dim onlyOdd = Aggregate num In numbers _                       Into All(num Mod 2 = 1)         Console.WriteLine("The list contains only odd numbers: " & onlyOdd)    End Sub End Class