hi cheers,,,

Jul 7 2015 9:53 AM
i am getting the error as :Index was out of range. Must be non-negative and less than the size of the collection
 
while i am trying to run this code.here is my code.... 
 
if (data != null)
{
kbs.LoanAmount = amount;
kbs.PaymentFrequency = "Monthly";
kbs.LoanTerm = Convert.ToInt32(terms);
kbs.FirstPaymentDate = data[0].ScheduleDate; here im getting the error
kbs.Cost1 = 5;
kbs.Cost2 = 1;
for (int i = 0; i < data.Count(); i++)
{
KabbageLoanSchedule kls = new KabbageLoanSchedule();
kls.PaymentNumber = i + 1;
kls.Principal = Math.Round(data[i].PrincipalPaid, 2);
kls.DaysToPayment = data[i].DaysBetweenSchedules;
kls.MinMonthlyCost = Math.Round(data[i].InterestPaid, 2);
kls.MinMonthlyPayment = Math.Round(data[i].ScheduledAmount, 2);
kls.PrincipalRemaining = Math.Round(am - data[i].PrincipalPaid, 2);
kls.PaymentDueDate = data[i].ScheduleDate;
am = kls.PrincipalRemaining;
lkbs.Add(kls);
}
dt.AddMonths(1);
}
 

Answers (1)