y s

y s

  • NA
  • 62
  • 23.6k

compare 2 keys to get value

Mar 30 2011 8:03 AM
I have an arrayList with key which are shown below:
1
2
3
1 2
1 3
3 1
2 3
1 2 3
2 3 1

I have another sortesList with key and value which shown below:
1:4
2:4
3:4
1 2:3
1 3:3
2 3:4
1 2 3:4

if the key in arrayList which is same with the key in sortedlist,
then will come out the value.
my expected output is :
1:4
2:4
3:4
1 2:3
1 3:3
2 3:4
1 2 3:4
2 3 1:4

how i compare this 2 keys and display it in another new sortedList?


Hope someone can help me. my coding are shown below:

ArrayList arryKey = new ArrayList();
double v;
foreach (String key1 in sortList2.Keys)
{
arryKey.Add(key1);
foreach (String key in arryKey)
{
if (sortList.ContainsKey(key))
{
sortList.TryGetValue(key1, out v);

richTextBox5.AppendText(key1 + " " + v +"\n");
}
}
}

Answers (16)