public static DetailedGameData FindLeastExpensiveGame(List <DetailedGameData> games) { DetailedGameData leastExpensive = null; int lowestCost = int.MaxValue; foreach (DetailedGameData dgd in games) { if (dgd.price_overview != null && dgd.price_overview.initial < lowestCost) { leastExpensive = dgd; } } return(leastExpensive); }
public static DetailedGameData FindMostExpensiveGame(List <DetailedGameData> games) { DetailedGameData mostExpensive = null; int highestCost = 0; foreach (DetailedGameData dgd in games) { if (dgd.price_overview != null && dgd.price_overview.initial > highestCost) { mostExpensive = dgd; } } return(mostExpensive); }