code_junkie

Why can't I .add a Dictionary(Key, Value) in a foreach?

Nov 13th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. Dictionary<string, string> persons = new Dictionary<string, string>();
  2.  
  3. persons.Add("roger", "12");
  4. persons.Add("mary", "13");
  5.  
  6. foreach (KeyValuePair<string,string> person in persons)
  7. {
  8. Console.WriteLine("Name: " + person.Key + ", Age: " + person.Value);
  9. persons.Add("Xico", "22");
  10. }
Add Comment
Please, Sign In to add comment