How to select min and max values of a column in a datatable?

Ahmed Atia picture Ahmed Atia · Mar 14, 2010 · Viewed 204.2k times · Source

For the following datatable column, what is the fastest way to get the min and max values?

AccountLevel  
0  
1  
2  
3 

Answer

Lalit picture Lalit · Feb 7, 2011

Easiar approach on datatable could be:

int minLavel = Convert.ToInt32(dt.Compute("min([AccountLevel])", string.Empty));