Hi all,
I have an dictionary of lists of objects as shown below:
IDictionary<string, IList> MyItemDictionary
I work out the percentages by doing a for each through the dictionary with the code below:
IList<double> percentages = new List<double>();
foreach(KeyValuePair<string, IList> pair in MyItemDictionary)
{
double percentage = (100d/totalItemsCount)*pair.Value.Count;
percentages.Add(percentage);
}
Basically I need to process the percentages list and round each percentage to a whole number BUT have them add up to 100. Accuracy is not of the highest importance but a sub 1 percentage i.e. 0.45 needs to be rounded to 1.
Does anyone know how to do this?
Thanks for your time and I look forward to your responses!
Adam