thanks for the help.
i have created the hashtable but im still having logic problems with the array creation hopefully you can help me.
What im stumped on is creating the array with repeated items based on another array..
So for the code below i create the hashtable then create a array called promoWeights. This array just has 8 numbers in it
5,3,1,1,2,1,3,4
<- those are the weights. So the first item in the
hashtable needs to go in an array 5 times, then the next
item needs
to go in three times, but i dont know how to re-index it
properly. i tried stuff like this but i cant figure it out.
Basiclly i need the algorythm to just take one array and duplicate values based on values in another array!
Can i use the array methods to do that, rather than looping. (Ie can i do array.copy[index] or something??)
HTANKS
for(int i=0;i<mynewArray.length;++i)
{
//repeat per weights
k=0
int topline = promoWeights[i ] + k
for(int k=k;k<promoWeights[i ];++k){
mynewArray[k] = promoWeights[i ];
}
But that repeats over the first index. i need to say OK NOW WERE AT ITEM 5 SO LETS SET THAT AS THE START POINT FOR K
foreach(XmlNode catNode in catNodes){
if(catNode.Attributes["name"].InnerText.ToString().ToLower() == catname.ToString().ToLower()){
promoWeights = new string[catNode.ChildNodes.Count];
int j = 0;
//go through nodes
foreach(XmlNode promoNode in (XmlNodeList)catNode.ChildNodes)
{
//add to hasthable
htPromos.Add(promoNode.ChildNodes[0].InnerText.ToString(),promoNode.ChildNodes);
//add weight to array
promoWeights[j] = promoNode.ChildNodes[5].InnerText.ToString();
totalWeight += Convert.ToInt32(promoNode.ChildNodes[5].InnerText);
++j;
}
techincal blogcorporate