public static int GetPreviousModel(List<int> models, int currentModel) { for (int c = 0; c < models.Count; c++) { if (models[c] == currentModel) { if (c == 0) { return models[models.Count - 1]; } else { return models[c - 1]; } } } return models[0]; }