Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

LINQ: difference entre ‘Union’ et ‘Concat’

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

using System;
using System.Collections.Generic;
using System.Linq;
 
namespace LINQ
{
public class ExempleConcatETUnion
{
    public static void Main() {
 
        int[] seq1 = { 1, 2, 3 };
        int[] seq2 = { 3, 4, 5 };
 
        IEnumerable<int> concat = seq1.Concat(seq2);    //  { 1, 2, 3, 3, 4, 5 }
        foreach (int elem in concat)
            Console.WriteLine(elem);
 
        // Exclut la répétition
        IEnumerable<int> union = seq1.Union(seq2);     //  { 1, 2, 3, 4, 5 }
        foreach (int elem in union)
            Console.WriteLine(elem);
    }
}
 
 }

No comments yet.

Leave a Comment