I have a set of values that are generated dynamically with a foreach loop, how can I add these into one value?
For instance, say I have a site where each node has a number associated with it. How can I add all these numbers together? So far I’ve figured it’d be something similar to the following, where the value of ‘node.aNumberValue’ is added to the next one, and so on:
@foreach (var x in nodes){
var total = node.aNumberValue + node.aNumberValue (etc...);
<p>@total</p>
}
This is what you want, I think:
Or even better, just: