I have a List and I want to convert it to a List. Is there any way to do this other than just looping through the Li
You can use Select as suggested by others, but you can also use ConvertAll:
List doubleList = intList.ConvertAll(x => (double)x);
This has two advantages:
ToList method doesn't know the size of the result of Select, so it may need to reallocate buffers as it goes. ConvertAll knows the source and destination size, so it can do it all in one go. It can also do so without the abstraction of iterators.The disadvantages:
List and arrays. If you get a plain IEnumerable you'll have to use Select and ToList.