using System;
using System.Linq;
namespace ConsoleApplication_C_Sharp
{
class Program
{
static void Main(string[] args)
{
int[] arr1 = { 1, 2, 3, 4, 5 };
int[] arr2 = { 3, 4, 5, 6, 9, 6 };
// If arr1 contains elements that exist in arr2 + 1
// 1+1=2 not exist
// 2+1=3 exist join 2
// 3+1=4 exist join 3
// 4+1=5 exist join 4
// 5+1=6 exist twice join 5 5
var result = arr1.Join<int, int, int, int>(arr2,
x => x + 1,
y => y,
(x, y) => x);
foreach (var n in result)
Console.WriteLine(n);
}
}
}
/*
run:
2
3
4
5
5
*/