Dictionary - Create, Fill, Iterate


/ Published in: C#
Save to your folder(s)

Working with System.Collections.Generic.Dictionary


Copy this code and paste it in your HTML
  1. using System.Collections.Generic;
  2.  
  3. // create
  4. Dictionary<int, bool> MyDictionary = new Dictionary<int, bool>();
  5.  
  6. // fill
  7. MyDictionary.Add(1, true);
  8.  
  9. // iterate
  10. foreach (KeyValuePair<int, bool> dictitem in MyDictionary)
  11. {
  12. if (dictitem.Key == 1)
  13. // ...
  14. }
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.