private int FindBestStartPointForLine(int line) { int best = 0; int bestDistance = int.MaxValue; for (int i = 0; i < lineCounters.Length; i++) { int distance = Math.Abs(lineCounters[i] - line); if (distance < bestDistance) { bestDistance = distance; best = i; } } return best; }