prints a list of numbers that are common to two integer arrays.
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class MainClass { public static void Main() { int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 }; int[] numbersB = { 1, 3, 5, 7, 8 }; var commonNumbers = numbersA.Intersect(numbersB); Console.WriteLine("Common numbers shared by both arrays:"); foreach (var n in commonNumbers) { Console.WriteLine(n); } } }
1. | use Linq Intersect to intersect two arrays | ||
2. | prints the first letter of a Product name and the first letter of a Customer name. | ||
3. | Intersect Operator |