Sum with integers : Sum « LINQ « C# / C Sharp






Sum with integers

 
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass {
    public static void Main() {
        IEnumerable<int> ints = Enumerable.Range(1, 10);
        foreach (int i in ints)
            Console.WriteLine(i);
        int sum = ints.Sum();
        Console.WriteLine(sum);
    }
}

 








Related examples in the same category

1.use Linq Sum to sum an array
2.use Sum to find the total of all of the numbers in an integer array.
3.Sum with Projection
4.Sum with object property
5.Grouped Sum