Advertisement
Guest User

Untitled

a guest
May 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. var dict3 = Dict.Where(entry => Dict_BM[entry.Key] != entry.Value)
  2. .ToDictionary(entry => entry.Key, entry => entry.Value);
  3.  
  4. var dict3 = Dict.ToDictionary(
  5. entry => entry.Key,
  6. entry => Dict_BM[entry.Key] == entry.Value);
  7.  
  8. var dict3 = Dict.Keys.Union(Dict_BM.Keys).ToDictionary(
  9. key => key,
  10. key => Dict.ContainsKey(key) &&
  11. Dict_BM.ContainsKey(key) &&
  12. Dict[key] == Dict_BM[key]);
  13.  
  14. var areEqual = Dict.SequenceEqual(Dict_BM);
  15.  
  16. Dictionary<string, int> Dictionary1 = new Dictionary<string, int>();
  17. d1.Add("data1",10);
  18. d1.Add("data2",11);
  19. d1.Add("data3",12);
  20. Dictionary<string, int> Dictionary2 = new Dictionary<string, int>();
  21. d2.Add("data3", 12);
  22. d2.Add("data1",10);
  23. d2.Add("data2",11);
  24. bool equal = false;
  25. if (Dictionary1.Count == Dictionary2.Count) // Require equal count.
  26. {
  27. equal = true;
  28. foreach (var pair in Dictionary1)
  29. {
  30. int tempValue;
  31. if (Dictionary2.TryGetValue(pair.Key, out tempValue))
  32. {
  33. // Require value be equal.
  34. if (tempValue != pair.Value)
  35. {
  36. equal = false;
  37. break;
  38. }
  39. }
  40. else
  41. {
  42. // Require key be present.
  43. equal = false;
  44. break;
  45. }
  46. }
  47. }
  48. if (equal == true)
  49. {
  50. Console.WriteLine("Content Matched");
  51. }
  52. else
  53. {
  54. Console.WriteLine("Content Doesn't Matched");
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement