I would like to convert the below "foreach" statement to a LINQ query that returns a substring of the file name into a list:
IList<string> fileNameSubstringValues = new List<string>();
//Find all assemblies with mapping files.
ICollection<FileInfo> files = codeToGetFileListGoesHere;
//Parse the file name to get the assembly name.
foreach (FileInfo file in files)
{
string fileName = file.Name.Substring(0, file.Name.Length - (file.Name.Length - file.Name.IndexOf(".config.xml")));
fileNameSubstringValues.Add(fileName);
}
The end result would be something similar to the following:
IList<string> fileNameSubstringValues = files.LINQ-QUERY-HERE;