i have a collection of objects. i need to loop through the collection and generate another collection. each item in the second collection is a function of two items in the first collections. So to simplify the problem.
Lets assume the collection is a set of ints.
List<int> myIntCollection = new List<int>() {1, 4, 6, 8, 7};
i need to generate a second collection in which each item is the sum of 2 of the items in the first collection. so the second collection would have these elements after the conversion.
List<int> generatedCollection = new List<int>() {5, 10, 14, 15};
as you can see the first element is 5 (which is the sum of the first two items in the top collection), the second elemtn is 10, which is hte sum of the second and third item in the first collection and so on . .
You can use a
forloop:That wasn’t hard!