Here is an example of the KeyIndex column (type int) in table DT2
1, through LINQ to achieve
int maxkeyindex = DT2. AsEnumerable (). Select (t = t.field<int> ("KeyIndex")). Max ();
LINQ syntax: Click to open link
2, through the compute method to achieve
int ee = (int) dt2.compute ("Max (KeyIndex)", "true");
Compute method: Click the Open link
3, through the Select method to achieve
int rr = (int) dt2. Select ("", "KeyIndex DESC") [0]["KeyIndex"];
Select method: Click the Open link
4. Go to List
To list the columns that need to be sorted in the DataTable, and then sort by the list's sort () method, the last value in the list is the maximum, after the sort is sorted by the default ascending order.
Introduction to List
The above is the content of the largest value in the returned column in the C # DataTable, more about topic.alibabacloud.com (www.php.cn)!