#

WE ARE SHARING

OUR EXPERIANCE.

BELIEVE THE POWER OF SHARE

BLOG

C # Linq "Intersect" Creating an Array of Common Values ​​of Two Arrays with the Neighborhood

C # Linq "Intersect" Creating an Array of Common Values ​​of Two Arrays with the Neighborhood

With C # Linq it is possible to pass common values in two different arrays to another array. In this example, a new array containing common values shared by both directories is created.

public void Linq() 

    int[] numbersA = { 0245689 }; 
    int[] numbersB = { 13578 }; 
    var commonNumbers = numbersA.Intersect(numbersB); 
    Console.WriteLine("Common numbers shared by both arrays:"); 
    foreach (var n in commonNumbers) 
    { 
        Console.WriteLine(n); 
    } 
}

 Return

Common numbers shared by both arrays:
5
8