1 private void GetCumulativePercentages() 2 { 3 cumulativePercentages.Clear(); 4 5 int cumulativePercent = 0; 6 cumulativePercentages.Add(cumulativePercent); 7 for (int i = 0; i < weightPercentages.Count; i++) 8 { 9 //Add the new item's probability 10 cumulativePercent += weightPercentages[i]; 11 12 //add the new percent as the key, and the index of the associated entry as the value 13 cumulativePercentages.Add(cumulativePercent); 14 } 15 }