Find longest string in Datatable column

前端 未结 3 856
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-14 06:05

I would like to know If It\'s possible to create a \"one-line\" Linq to retrieve longest string value of specific Datatable column, meaning that all column data (numbers, dates,

3条回答
  •  盖世英雄少女心
    2021-02-14 06:36

    First of all do not use AsEnumerable right after dt.. Write somehow like this:

    dt.OrderByDescending(row => row[mycolumn].Length).First();
    

提交回复
热议问题