If you happen to know the type of the collection of FileInfo
s, and it's a List<FileInfo>
, I'd probably skip the Linq and write:
files.ConvertAll(
file => file.Name.Substring(0, file.Name.Length - (file.Name.Length - file.Name.IndexOf(".config.xml")))
);
or if it's an array:
Array.ConvertAll(
files,
file => file.Name.Substring(0, file.Name.Length - (file.Name.Length - file.Name.IndexOf(".config.xml")))
);
Mainly because I like saying "Convert" instead of "Select" to express my intent to a programmer reading this code.
However, Linq is part of C# now, so I think it's perfectly reasonable to insist that a reading programmer understand what Select
does. And the Linq approach lets you easily migrate to PLinq in the future.