Sum integers from Enumerable.Range in CSharp
Description
The following code shows how to sum integers from Enumerable.Range.
Example
//from w w w . j ava2 s .com
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);
}
}
The code above generates the following result.