Min and Max operator in LINQ using VB.NET

This article defines the Basic use of the Min and Max operator in LINQ.
  • 5510

Min operator

The Min operator is used to find the minimum value from a sequence of numeric values.

Example

The following example finds the lowest number from a sequence of numeric values.

Module Module1

    Sub Main()

        Dim num As Integer() = {11, 35, 3, 7, 45, 87, 78, 43}

        Dim smallnum As Integer = num.Min()

        Console.WriteLine("The smallest number is :" & smallnum)

    End Sub

End Module

 

OUTPUT
 

min-operator.gif

Max operator

The Max operator is used to find the largest value from a sequence of numeric values.

Example

The following example finds the maximum number from a sequence of numeric values.

Module Module1

    Sub Main()

        Dim num As Integer() = {11, 35, 3, 7, 45, 87, 78, 43}

        Dim maxnum As Integer = num.Max()

        Console.WriteLine("The larger number is :" & maxnum)

    End Sub

End Module

 

OUTPUT
 

max-operator.gif

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.