c#

How to get Max String Length in every Column of a Datatable

A
Desh-Duniya Team Author
| Published August 07, 2019
var maxLengthForColumns =
                Enumerable.Range(0, dt.Columns.Count)
                .Select(col => dt.AsEnumerable()
                                     .Select(row => row[col]).OfType<string>()
                                     .Max(val => val?.Length )).ToList();

Discussion (0)

Please sign in to participate in the discussion.
No comments yet. Be the first to join the conversation!