public void CalculateZones() { var orderedTurningPoints = TurningPoints.OrderBy(x => x); _zones = new List <SpZone>(); var latestZone = new SpZone(0); foreach (var orderedTurningPoint in orderedTurningPoints) { if (latestZone.Contains(orderedTurningPoint)) { latestZone.Add(orderedTurningPoint); } else { latestZone = new SpZone(orderedTurningPoint); _zones.Add(latestZone); } } Console.WriteLine(_zones.Count); var orderstrength = _zones.OrderByDescending(x => x.Price); foreach (var spZone in orderstrength) { Console.WriteLine(spZone); } }
public void CalculateZones() { var orderedTurningPoints = TurningPoints.OrderBy(x => x); _zones = new List<SpZone>(); var latestZone = new SpZone(0); foreach (var orderedTurningPoint in orderedTurningPoints) { if (latestZone.Contains(orderedTurningPoint)) { latestZone.Add(orderedTurningPoint); } else { latestZone = new SpZone(orderedTurningPoint); _zones.Add(latestZone); } } Console.WriteLine(_zones.Count); var orderstrength = _zones.OrderByDescending(x => x.Price); foreach (var spZone in orderstrength) { Console.WriteLine(spZone); } }