int[] arraySearch = { 1, 2, 3, 4, 5, 6, 7, 8 }; int target = 6; var index = -1; for (int i = 0; i < arraySearch.Length; i++) { if (arraySearch[i] == target) { index = i; } } Console.WriteLine(index);