How to sum a list of int numbers in C#

1 Answer

0 votes
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6 };

        int sum = list.Sum();

        Console.WriteLine(sum);
    }
}



/*
run:

21

*/

 



answered May 25, 2019 by avibootz

Related questions

1 answer 415 views
1 answer 97 views
1 answer 116 views
116 views asked May 25, 2019 by avibootz
...