public static void Main()
Console.WriteLine("Hello World");
int[] firstArray = {2,4,6,8,10};
int[] secondArray= {1,2,3,5,6,8,9};
var result = ArrayIntersection(firstArray, secondArray);
foreach(int element in result)
Console.WriteLine(element);
public static int[] ArrayIntersection(int[] firstArray, int[] secondArray)
int firstArrayLength = firstArray.Length;
int secondArrayLength = secondArray.Length;
int[] resultArray = new int[firstArrayLength + secondArrayLength];
while(i < firstArrayLength || j < secondArrayLength)
if(i >= firstArrayLength)
resultArray[k] = secondArray[j];
else if(j >= secondArrayLength)
resultArray[k] = firstArray[i];
else if(firstArray[i] < secondArray[j])
resultArray[k] = firstArray[i];
else if(firstArray[i] > secondArray[j])
resultArray[k] = secondArray[j];
resultArray[k] = firstArray[i];