0

Hi,i am doing window form using VB C#.
My problem as below:

Dictionary<string, double> sortList1 = new Dictionary<string, double>();//contain key and //values

Dictionary<string, double> sortList2 = new Dictionary<string, double>();//empty


// do events                                                           

                int j = 0;
                foreach (double doub5 in sortList1.Values)
                {
                    holder = (doub5 * 100 / richTextBox2.Lines.Length) * bt;                      
                    j++;
                }      

i wants to store the keys of sortList1 and the new values (holder) into sortList2. How to do? Thanks you.

Edited by mike_2000_17: Fixed formatting

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by leo88
0

Impossibe in these kind of collections.
You cannot store type string into type of variable.
What do I mean: your 1st array has the string as for a key, and 2nd array`s Value is the double.
Chanage that. Then you simply code the key from array1 to the value of array2.

Do a loop of KeyValuePair<sting, double> of the dictionary1, and pass the key of the current to the value of the 2nd dictionary.

Mitja

0

If like that , is it possible to overwrite/replace the values of sortList1 with the new values(holder) on the Dictionary?

0

I means for each specific keys:
sortList1

Key Value
2 49
3 70
5 10
6 10

i want to replaces the value with new values (holder) for each specific key. holder is the values after compute by formula statement.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.