.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> LINQ >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Aggregate and Sum in LINQ

Posted By:papsantony       Posted Date: August 12, 2010    Points: 10    Category: LINQ    URL: http://www.dotnetspark.com  

linq
 

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

public class MainClass {
    public static void Main() {
        IEnumerable intSequence = Enumerable.Range(1, 10);
        foreach (int item in intSequence)
            Console.WriteLine(item);
        int sum = intSequence.Aggregate(0, (s, i) => s + i);
        Console.WriteLine(sum);
    }

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend