C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Comparing Hash Tables


Posted Date: 03 Nov 2009      Posted By: divya jain      Member Level: Bronze     Points: 1   Responses: 2



Hi friends

i have to compare two hash tables on key to key basis and have to insert the unmatched key into a arrarylist how it is possible in VB.NET

comparision is like

hashtable1.key1=hashtable2.key1





Responses

Author: Hari    03 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi

you do something like this

Hashtable table = new Hashtable();
table.Add(1, "one");

Hashtable table1 = new Hashtable();
table1.Add(12, "twelve");

if (table.ContainsKey(1) && table1.ContainsKey(12))
{
}



Author: Deepthi    03 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

hi,

i want to modify what hari has written i.e,
instead of using if, use nested foreach i.e
foreach(key(datatype) i in table)
{
foreach(key(datatype) j in table1)
{
if(i == j)
continue;
//check if i and j are in ur arraylist, if not then
//add to ur arraylist the key i and j here
}
}
this way u collect ur unmatched keys from both the hashtables.
try it...

regards
deepthi



Post Reply
You must Sign In to post a response.
Next : TextBox Quantity and HiddenField values are not passed on?
Previous : Accordion Menu
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use