Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intersect two arrays

How can I find the intersecttion between 2 arrays in C#, in a fast way?

like image 414
Haim Evgi Avatar asked Nov 22 '10 17:11

Haim Evgi


People also ask

What is intersection of two arrays in Java?

To find the intersection of two arrays in java use two loops. The outer loop is to iterate the elements of the first array whereas, the second loop is to iterate the elements of the second array.

How do you find the intersection of two arrays in Matlab?

C = intersect( A,B ) returns the data common to both A and B , with no repetitions. C is in sorted order. If A and B are tables or timetables, then intersect returns the set of rows common to both tables.


1 Answers

There's the Intersect extension method on Enumerable. It works on any IEnumerable<T> including arrays.

like image 59
Brian Rasmussen Avatar answered Sep 29 '22 11:09

Brian Rasmussen