Well, it's gonna be rather hard to use IEnumerable<T>
extensions methods if you use an Hashtable instead of a Dictionary<TKey, TValue>
.
Because an Hashtable is not a generic type.
So there's no Hashtable.Union
available, nore Hashtable.Keys.Union
.
You would have to do something like
hashtable1.Keys.Cast<int>().Union(hashtable2.Keys.Cast<int>());
But... what will happen if keys are not int ?
If you change Hashtable
to Dictionary<TKey, TValue>
, you'll be able to do things like
var resultDictionary = dic1.Intersects(dic2).ToDictionary(m => m.Key, m => m.Value);
var resultDictionary = dic1.Except(dic2).ToDictionary(m => m.Key, m => m.Value);