I tried replacing the code
foreach (var discovery in mpwrapper.parser.Discoveries) { solution.AddFile("Discoveries", discovery.DisplayStringName + ".mpx", discovery); }
with the following linq expression
mpwrapper.parser.Discoveries.Select( s => solution.AddFile("Discoveries", s.DisplayStringName + ".mpx", s));
But an error was received
Type arguments for the method 'System.Linq.Enumerable.Select (System.Collections.Generic.IEnumerable, System.Func)' cannot be taken out of use. Try to explicitly specify the type arguments.
How to convert this foreach loop to linq request where I execute a method for every object in my IEnumerable collection?
source share