Intersect
In this chapter you will learn:
Get to know Intersect operator
Intersect
returns the elements that two sequences have in common.
using System;/*j ava 2 s . c o m*/
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:
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Linq Operators