int[] items = new int[] { 1, 2, 3, 2, 7, 4, 2, 8, 9, 1, 2, 10, 11, 3, 4, 10 };
int k = 10, l = 2;
int first =k, second = l;
List<int> between = new List<int>();
for (int i = 0; i < items.Length; i++)
{
if(items[i] == k)
{
first = k;
second = l;
}
if (items[i] == l)
{
first = l;
second = k;
}
if (items[i] == first)
if (i - 1 < items.Length)
for (int j = i + 1; j < items.Length; j++)
{
if (items[j] == second)
{
between.Add(j - i -1);
}
}
}
k
,
l
: are your 2 numbers
between
: is a list that returns your values.