i have a problem about compare arrayList and sortedlist.
my arrayList are shown below:
1 2
1 3
1 2
2 3
1 2 3
1 3
2 3
1 2 3


my another sortedeList are shown below:
(1): 4
(2): 4
(1 2): 3
(3): 4
(1 3): 3
(2 3): 3
(1 2 3): 2

Now my problem is i want to compare arrayList with sortedList . if the key are same, then will show value.
my expected output is :
1 2:3
1 3:3
1 2:3
2 3:3
1 2 3:2
1 3:3
2 3:3
1 2 3:2

my code are below:

Dictionary<string, double> sortList8 = new Dictionary<string, double>();
            string sigh = "";
            foreach (string ry in ang)
            {
                if (sortList2.ContainsKey(ry))
                {
                    if (!sortList8.ContainsKey(ry))
                    {
                        sortList8.Add(ry, sortList[ry]);
                        sigh += String.Format("{0}:{1}\r\n", ry, sortList8[ry]);
                    }
                }
            }
        
        richTextBox12.Clear();
   richTextBox12.AppendText(sigh);

hope someone can help me..thx..

I really wish you'd use meaningful variable names. sortList# doesn't tell us anything about what it actually is. I'm guessing that sortList2 is actually a Dictionary and that the parts before the : are the key, after the : is the value. Do these keys actually have the () around them? If so, you'll never match anything.

Also, your code excludes the output of repeated values ("1 2" for example) but your sample output allows for them. Which is it? And what's sortList8 have to do with anything?

Would it be possible to post the actual description of the entire problem you are trying to solve?

ddanbe: my car has some problems too. But I am really not sure what to do now...
PS: I will stop answering on these kind of not-even-half-explined-threads.

sortList 2 is dictionary, front part are key adn after the : is value. the () will be remove. Actually i wan to repeat the output ( 1 2 for example). based on my coding , i cant make it repeat. may i know wat's problem with my coding? is there anything wrong with my coding?

In line 7 you are checking if the key already exists in sortlist8. If it does then nothing will be output for that key. Move the output to outside that check if you want something output for every key.

What is the description of the actual problem you are trying to solve?

5

Thanks , i get it.
i m doing a project about mining negative association rules.
i need use get the value, then calculate the confidence and lift to get the negative association rules.

hi, i meet another problem .
that is i need to use the value from sortlist8 to do calculation .

My total transaction is 5.
for example-> 1 2:3
therefore, i need to use the value divide by total transaction.
now my problem is i just can show some only.
here is my coding.

string b = txtTotalItems.Text;
             double e = Double.Parse(b);
            double a;

            richTextBox9.Clear();
            foreach (double wee in sortList8.Values)
            {
                a = (wee / e);
                richTextBox9.AppendText(a.ToString() + "\n");

hope can help me ^^

This article has been dead for over six months. Start a new discussion instead.