I have some List:
List list = new List { 1, 2, 3, 4, 5 };
I want to apply some transformation to elements of my list.
The first answer should not be the accepted one. I am a former 2007 C# Microsoft MVP.
In contrast to the accepted response, ConvertAll is much more efficient than the combination of Select and ToList().
First of all, ConvertAll is strictly faster and it uses the minimum amount of memory to do so. Same as Array.ConvertAll vs Select and ToArray. This would be a much more evident with a larger length array or many calls within a loop.
1) ConvertAll knows the size of the final list and avoids reallocating the base array. ToList() will keep resizing the array multiple times.
2) ToList will make slower interface IEnumerable<> calls, while ConvertAll will loop through the underlying array without extra calls or range checks.
3) Select will create an extra IEnumerable object.