Except
returns the elements in the first input sequence that are not present in the second:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int[] seq1 = { 1, 2, 3 };
int[] seq2 = { 3, 4, 5 };
IEnumerable<int> difference1 = seq1.Except(seq2);
IEnumerable<int> difference2 = seq2.Except(seq1);
foreach (int i in difference1)
{
Console.WriteLine(i);
}
foreach (int i in difference2)
{
Console.WriteLine(i);
}
}
}
The output:
1
2
4
5
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |