3 ms·
that's the same as var foo= new List<int> {1, 2, 3}; var bar = foo.Select(x => x*2);
by WorkerBee 16y ago
that's the same as
var foo= new List<int> {1, 2, 3};
var bar = foo.Select(x => x*2);
- nlawalker 16y agoYep, one thing to realize is that LINQ does not simply refer to the query syntax - it refers to a set of technologies, including expression trees and the ability to compile them to alternate languages like TSQL, the query syntax, and the extension methods like Select. One small difference with your example though is that Select requires "using System.Linq", and ConvertAll is defined on List<T>.
- bluetech 16y agoAnd of course, the LINQ version returns an IEnumerable<TResult>, while the List version return List<TResult>. You could chain a .ToList() there to make them equivalent (if needed).