I have a list that contains some values I want to calculate the sum of every 4 items in this list and then I have to put it in a list.
for example:
list 1=[1,2,3,4,5,6,7,8]
output= [10,26]
I have a list that contains some values I want to calculate the sum of every 4 items in this list and then I have to put it in a list.
for example:
list 1=[1,2,3,4,5,6,7,8]
output= [10,26]
2
Answers
You can play with snippet.
You can use this custom-made extension method to sum every n in a `List“, just add it inside your file outside your classes :
And use it in your code like this:
You can also customize the n from the method to sum for any other n.