Posted By

leonbda on 01/21/09


Tagged

dictionary


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Dictionary - Create, Fill, Iterate


 / Published in: C#
 

Working with System.Collections.Generic.Dictionary

  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  

You need to login to post a comment.