My question is simple, and I am quite sure the answer must be already here on SO, but could not find it.
And guys, an array is not a list and not an IEnumerable!!! Or are you telling me I HAVE to convert it to a list?
I want to get the index of a subarray (the first one) using Linq.
int[] arr= new int[] { 1, 5, 3, 2, 4 };
int[] sub= new int[] { 3, 2 };
int index = ? // Expected result 2
I looked at Array.FindIndex
and Array.IndexOf
, but couldn't figure it out.
Convering it to lists does not seem a very good plan. This has a dramatic performance:
List arrList = ((int[])arr).ToList(); List subList = ((int[])sub).ToList();
Thanks