I am trying to get the Max value from a datatable using LINQ query.
var maxVal =(from rowmax in datatable.AsEnumerable()
where rowmax.Field<string>(column name A)=="1000"
&& rowmax.Field<string>(column name B)=="36"
select rowmax.Field<string>(column name C)).Max();
I have the values in Column C like (154.93445, 142.05789,110.45632 and 94.34623 and so on) which are smaller than these numbers. But when I am doing above query for MAX i am getting 94.34623 but not 154.93445. I want to fetch the max number which is 154.93445.
Please suggest what I am doing wrong.
Max 是在字符串而不是数字上调用的,您需要进行某种从字符串到浮点类型的转换。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.