Using Linq is there a way to perform an operation on every element in an Array

c#, linq

Solution

var foo = new int[] { 1,2,3,4,5 };
foo = foo.Select(x=>x/2).ToArray();

Problem

If I have an array ``` var foo = new int[] { 1,2,3,4,5 }; ``` Using `linq` can I perform an operation on each element instead of doing something like this? ``` for (int i = 0; i < foo.Length; i++) { foo[i] = foo[i] / 2; //divide each element by 2 } ```

Original source