C#
var lst = new List { };
lst.Add(("Germany", "83 Millionen", 16));
lst.Add(("USA", "328 Millionen", 40));
lst.Add(("Spain", "46 Millionen", 5));Hi,
How can I use "lst.Sum" to get the sum of the 3rd column (16 + 40 + 5) ? (What is the syntax) ?
int sum= lst.Sum( ?
Thanks!!

Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 28, 2023, 4:31 AM EST
Hello Chris,
Use below code.
int sum = lst.Sum(x => x.number);Thanks
Naimish Makwana