Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Keyvalue pair problems

$
0
0

Hi all 

I have this code that adds values to a keyvalue pair. It works fine except the first keyvalue pair that returns the value of the last entry in the lexicon (see an example). How can i fix this?

  for (int x = 0; x < CharacterComboBox.Items.Count; ++x) 
                    for (int i = 0; i < files.Length ; ++i)
                {
                 string  behaviour_files = Path.GetFileName(files[i]);
                    if (behaviour_files.Contains("template"))
                    {
                       if (!File.Exists (absolute + "rule_input_" + character_names[x] + "_template.xml")){
                            string oldname = absolute + behaviour_files;
                            string newname = absolute + "rule_input_" + character_names[x] + "_template.xml";
                            FileInfo f = new FileInfo(oldname);
                            f.CopyTo(newname);
                            string new_files = Path.GetFileName(newname);
                            BehaviorCombo.Items.Clear();
                            BehaviorCombo.Items.Add(new_files);
                            BehaviorCombo.SelectedItem = new_files;
                            if (!m_charToRuleFileMap.ContainsKey((string)CharacterComboBox.Items[x]))
                            m_charToRuleFileMap.Add((string)CharacterComboBox.Items[x], new_files);   
                    }
                        }
                }
        }
Output of the above method.  The first entry should say Argentina=rule_input_Argentina_template.xml. What am i doing wrong?
Argentina=rule_input_Rwanda_template.xml
China=rule_input_China_template.xml
Australia=rule_input_Australia_template.xml
Morocco=rule_input_Morocco_template.xml
UnitedKingdom=rule_input_UnitedKingdom_template.xml
Korea=rule_input_Korea_template.xml
France=rule_input_France_template.xml
Pakistan=rule_input_Pakistan_template.xml
Togo=rule_input_Togo_template.xml
Luxembourg=rule_input_Luxembourg_template.xml
Azerbaijan=rule_input_Azerbaijan_template.xml
Guatemala=rule_input_Guatemala_template.xml
USA=rule_input_USA_template.xml
Russia=rule_input_Russia_template.xml
Rwanda=rule_input_Rwanda_template.xml


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>