using System.Collections.Generic;
public static void Main()
var myArray = new int[] {1, 2, 3, 4, 2, 4, 6, 7, 8};
var newArray = GetElementsAfterLastX(myArray, WhereFunction);
foreach(var e in newArray)
private static bool WhereFunction(int value)
private static IEnumerable<T> GetElementsAfterLastX<T>(T[] myArray, Func<T, bool> whereFunction)
throw new ArgumentNullException("myArray");
.Select((Value, Index) => new { Value, Index })
.Where(item => whereFunction(item.Value))
throw new Exception("Element Not Found");
return myArray.Skip(index + 1).Take(index).ToList();