chris combe

chris combe

  • 1.7k
  • 22
  • 2.5k

List (multidimentional) : How to get the sum of the 3rd column ?

Feb 28 2023 9:21 AM
var lst = new List<(string country, string population, int number)> { };

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!!

 


Answers (1)