Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

LINQ: Exemple simple d’utilisation d’agrégat

LINQ, All, Any, Concat, Contains, Agrégat, Union, Select, Order, From, Where
{filelink=15063}

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
 
namespace LINQ
{
 
public class ExempleProtoType
{
    public static void Main()
	{
        int X = 5;
        IEnumerable<int> laQueue = Enumerable.Range(1, X);
        foreach (int elem in laQueue)
        Console.WriteLine(elem);
 
        // Calucule la factorielle de 'X'
        int ag = laQueue.Aggregate((av, e) => av * e);
        Console.WriteLine("{0}! = {1}", X, ag);
 
    }
}
 
}
 
/*
 *  Résulats:
 *  1
    2
    3
    4
    5
    5! = 120
 
 * */

No comments yet.

Leave a Comment