in this code, i try to insert element in array by foreach loop....lucky i tell you, it success insert in array but, its just insert a new element after one shot of foreach loop..for example, in foreach loop, its return two element just in code below...for the first time, it success into array and when i invoke it by MessageBox.Show, its tells us that terms[0] = 5....then for the second foreach loop, its return to terms[0] = 3....i dont want these but i want kinda array that in final, its outcome is terms[0] = 5 3....just imagine, the value for string[] l is 12...my intention to display terms[0] = 5 3 is because, i want these result insert into getMaxValue(terms)....so, that, value from that array will play around in that method to find a max value....thats my goal...find a maximum value...can u guys help me....its awesome if u can help me out from this problem...im stuck here for 2 weeks...
this is a parent code before a child code at below
private Dictionary<string, double> GenerateCandidates(Dictionary<string, double> dic_FrequentItems, Dictionary<string, double> dic_FrequentItemsL1)
{
List<clssRules> lstSingleElementReturn = new List<clssRules>();
Dictionary<string, double> dic_CandidatesReturn = new Dictionary<string, double>();
for (int i = 0; i < dic_FrequentItems.Count - 1; i++)
{
string strFirstItem = Alphabetize(dic_FrequentItems.Keys.ElementAt(i));
for (int j = i + 1; j < dic_FrequentItems.Count; j++)
{
string strSecondItem = Alphabetize(dic_FrequentItems.Keys.ElementAt(j));
string strGeneratedCandidate = GetCandidate(strFirstItem, strSecondItem);
string[] l = strGeneratedCandidate.Split(' '); //1,2 --> 1 and 2
GetSingleElement(l, dic_FrequentItemsL1, strGeneratedCandidate);
MessageBox.Show("juon");
if (strGeneratedCandidate != string.Empty)
{
strGeneratedCandidate = Alphabetize(strGeneratedCandidate);
double dSupport = GetSupport(strGeneratedCandidate);
dic_CandidatesReturn.Add(strGeneratedCandidate, dSupport);
}
}
}
return dic_CandidatesReturn;
}
this a child code
double sqq;
private Dictionary<string,double> GetSingleElement(string[] l, Dictionary<string, double> dic_FrequentItemsL1, string strGeneratedCandidate)
{
Dictionary<string, double> value = new Dictionary<string, double>();
Dictionary<string, double> dic_MaxReturn = new Dictionary<string, double>();
string qq = "";
foreach (string v in l)
{
double[] terms = new double[l.Length];
string a = v.Replace("\r\n", " ");
foreach (var s in a)
{
qq = s.ToString();
MessageBox.Show(qq, "q");
sqq = dic_FrequentItemsL1[qq];
MessageBox.Show(sqq.ToString());
terms[0] = sqq;
MessageBox.Show(terms[0].ToString(), "terms[0]");
getMaxValue(terms);
}
dic_MaxReturn.Add(strGeneratedCandidate, getMaxValue(terms));
}
return dic_MaxReturn;
}
public static double getMaxValue(double[] numbers)
{
double maxValue = numbers[0];
for (int i = 1; i < numbers.Length; i++)
{
if (numbers[i] > maxValue)
{
maxValue = numbers[i];
}
}
return maxValue;
}
haha..sorry, i do some little mistakes in topics...its not How to Insert value in string using foreach loop but its more to How to Insert value in array using foreach loop...sorry guyss..

New Topic/Question
Reply



MultiQuote





|