1、经由过程linq来完成
int maxKeyIndex = dt2.AsEnumerable().Select(t => t.Field<int>("keyIndex")).Max();
Linq语法:点击翻开链接
2、经由过程Compute要领来完成
int ee = (int)dt2.Compute("Max(keyIndex)", "true");
Compute要领:点击翻开链接
3、经由过程Select要领来完成
int rr = (int)dt2.Select("", "keyIndex DESC")[0]["keyIndex"];
Select要领:点击翻开链接
4、转List
将DataTable中须要排序的列转List,然后经由过程list的Sort()要领来排序,默认值升序的即排序完成后,list中的末了一个是最大值。
List简介
以上就是C# DataTable中返回列中的最大值的内容,更多相关内容请关注ki4网(www.ki4.cn)!