combining hash tables and writing to file
<p>i have 2 hash tables that i have created. Of those 2 hash tables, they both have the same key, but different values. I have sorted both of the hash tables using a sorted list to have the keys in order on both tables. What i am attempting to do is have both hash tables written to a text file, and in this text file, it will have the Key (which is the same in both hash tables) with the value from hash table one and the value from hash table 2 next to it. The data is separated by a TAB and will look something like what is below:</p>

<pre><code>Key Value  Value
128   123      6
143   255      4
</code></pre>



<pre><code>Hashtable frequency = new Hashtable();
Hashtable grouplist = new Hashtable();

SortedList Grp = new SortedList (grouplist);
SortedList Freg = new SortedList(frequency);

foreach (DictionaryEntry entry in Grp)
{
    foreach (DictionaryEntry maxval in Freq)
    {
            file.Write(entry.Key);
            file.Write("\t");
            file.Write(entry.Value);
            file.Write("\t");

            if(Freq[entry.Key].Equals(Grp[maxval.Key]))
            {
                file.WriteLine(maxval.Value);
            }
     }
}
</code></pre>

<p>I have tried numerous ways to  get it to write just the Key and Value from one hash table and the value from the second hash table, but it just repeats writing each Key 75 times (which is the total number of Keys both Hash Tables.</p>

<p>I have many variations of the above code and they all do the same thing (can post them if needed). Any help would be appreciated.</p>

<p>Also, the only way i can get it to work and write what is needed (75 times each) is if i put a - ! - in the if statement, even though both Keys are the same. I even checked to make sure they were the same when debugging the program.
- Thanks</p>
