2

I have a datatable called table1 with a column called column1 that is an integer.

How can i get the max value of the column with a lambda expression in vb net?

thanks!

user3401335
  • 2,335
  • 2
  • 19
  • 32

1 Answers1

4
Dim max As Int32 = table1.AsEnumerable().
    Max(Function(r) r.Field(Of Int32)("column1"))

or in query syntax, what is often more readable in VB.NET:

Dim values =  From row In table1.AsEnumerable()
              Select row.Field(Of Int32)("column1")
Dim maxValue As Int32 = values.Max() 
Community
  • 1
  • 1
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939