Efficiency, of course, will not be worse in your case, if not better.
But if you want to be brief, try lambdas with LINQ:
lines.Aggregate((a, b) => Math.Max(a.Length, b.Length));
Btw, a minor point: you can technically stop reading if the amount of data remaining is less than the longest line you found. This way you can technically save a few steps, although this is probably not worth the code.
Itβs completely inappropriate, but only because I feel that this is an (elegant!) Version of the circuit:
(reduce max (map length lines))
Mehrdad
source share