sum of numbers from 1 to 10 using LINQ

Ddd
Posted by Ddd under LINQ category on | Points: 40 | Views : 3029
//print the sum of 1st 10 numbers .
using System;
using System.Linq;

class demo
{
static void Main()
{
var b=Enumerable.Range(1,10);
var q=b.Aggregate((t,i)=>t+i);
Console.WriteLine("sum is"+"---"+q);
}
}

Comments or Responses

Login to post response