wannabe_coder

What's the most efficient way of accomplishing this

Would I need to do some kind of "sort"







Re: Visual C# General Finding matching key values between two Hashtables

Anu Viswan

hi

Can you please explain your requirement litte more

thanks






Re: Visual C# General Finding matching key values between two Hashtables

Kea

I guess you want to find the union of two hashtables' keyset:

public static System.Collections.Hashtable UnionByKey(System.Collections.Hashtable a, System.Collections.Hashtable b)
{
System.Collections.Hashtable result;

if (a == null || b == null)
throw new ArgumentNullException("Two valid hashtable references required.");

result = new System.Collections.Hashtable(Math.Max(a.Count, b.Count));
foreach (object o in a.Keys)
{
if (b.ContainsKey(o))
result.Add(aTime);
}
return result;
}


I don't think sorting is necessary, as hashtables already serve the purpose of quick lookup. Please note that I didn't test this code, but it is similar to some assignment I did in Java.