How to add multiples variable ints from a foreach loop

I can’t think a way of adding the multiples ints returned from the foreach loop.135357-calculate.png

on the image above you can see that the foreach loop, loop through a set amount of childs and then returns the “SubConta” int from each child, but then i can’t think of a way to add all those returned ints from the loop to result a total from them.

You just want to get the ints and add them all up? If so, just add to an int from outside the loop.

        var total = 0;

        foreach(Transform child in Lineholder.tranform)
        {
            var linha = child.GetComponent<Linha>();

            if(linha != null)
            {
                total += linha.SubConta;
            }
        }

        Debug.Log(total);