This works (Visual Basic .NET) but seems comically long with all the LINQ to Object methods and in place dimensioning.
For Each PNGFile As System.IO.FileInfo In New System.IO.DirectoryInfo(Server.MapPath(".\Archive")).GetFileSystemInfos("*.png", System.IO.SearchOption.AllDirectories).OrderByDescending(Function(f) f.LastWriteTimeUTC).Skip(PageSize * Page).Take(PageSize)
'Do stuff with PNGFile
Next
I love that it’s all on one line and I think it even reads logically for myself. But my gut tells me it’s readability for the next poor soul having to interpret my code is non-existent. Or is it? How do you decide? Is it worth it to split this line into multiple other dimensioning and assignment statements? How would you break this particular line up as an example?
I’m new to .NET, but I’ve been writing code for 10+ years now. To date, I have determined my maximum line length in code based on the typical resolution I employ when creating the code. This can’t be the best way to decide…
I usually split lines on a new LINQ extension method, looks cleaner to me: