Skip to main content
1 of 2
sll
  • 62.7k
  • 22
  • 109
  • 157

First thing - use typed Dictionary<TKey, TValue> rather than Hashtable, below is example when values are of string type, this would be easy changing string to your custom type (I believe enum or already string constants).

IDictionary<string, string> map1 = new Dictionary<string, string> { {"A", "M1-A"}, {"B", "M1-B"}, {"C", "M1-C"} }; IDictionary<string, string> map2 = new Dictionary<string, string> { {"A", "M2-A"}, {"B", "M2-B"}, {"D", "M2-D"} }; 

(.NET 3.5 and upper) Usign LINQ Intersect():

var items = map1.Keys.Intersect(map2.Keys) .Select(k => map1[k] + " / " + map2[k]) .ToList(); OUTPUT: M1-A / M2-A M1-B / M2-B 
sll
  • 62.7k
  • 22
  • 109
  • 157