Intersect returns the elements that two sequences have in common.
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> commonality = seq1.Intersect(seq2);
foreach (int i in commonality)
{
Console.WriteLine(i);
}
}
}
The output:
3
| w___w__w.j_av_a___2__s___._c__om___ | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |