for (Int16 i = 1; i <= 6; i++ ) { insertCommand.Parameters.Add(String.Format("@pr_ctr_{0}", i), SqlDbType.Int).Value = drItem.Field<Int32>(String.Format("pr_ctr_{0}", i)); insertCommand.Parameters.Add(String.Format("@PC{0}Amt", i), SqlDbType.Money).Value = splitAmounts[i-1] ; }splitAmounts variable defined as
List<Decimal>I want to prevent possibility of that list having less than 6 elements, so in this case I would assign 0 to my parameter. Is there a way to do it in one line (change the last line) or I should add an extra if to check
i-1 < splitAmounts.Count
?