public static double GetTotalCost(int months, DistributionByAccountTypeDTO capitalCosts) { var endOfSpendMonth = (FormulaBase.FindEndOfSpendMonth(months, capitalCosts) ?? 0) + 1; var spendByMonth = FormulaBase.GetSpendForAccountType(months, capitalCosts, CustomerConstants.CAPEXAccount); double totalInvestmentCost = 0; if (spendByMonth == null) { return(0); } for (int i = 0; i < months; i++) { totalInvestmentCost += (spendByMonth[i] ?? 0); } return(totalInvestmentCost); }