fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var dictionary = new Dictionary<string, string>();
  9. dictionary["a"] = "A";
  10. dictionary["b"] = "B";
  11. dictionary["c"] = "C";
  12. dictionary["d"] = "D";
  13. Console.WriteLine("before removing...");
  14. foreach(var entry in dictionary) {
  15. Console.WriteLine("key: {0}, value: {1}", entry.Key, entry.Value);
  16. }
  17. var keysToRemove = new List<string> {
  18. "a", "b", "c"
  19. };
  20. Console.WriteLine("after removing...");
  21. keysToRemove.ForEach(key => dictionary.Remove(key));
  22. foreach(var entry in dictionary) {
  23. Console.WriteLine("key: {0}, value: {1}", entry.Key, entry.Value);
  24. }
  25. }
  26. }
Success #stdin #stdout 0.03s 14936KB
stdin
Standard input is empty
stdout
before removing...
key: a, value: A
key: b, value: B
key: c, value: C
key: d, value: D
after removing...
key: d, value: D