-
January 15th, 2012, 09:41 AM
#1
How to access a hashtable inside another hashtable?
I have 2 hashtables:h1 and h2..
Here I require to use a hashtable within another hashtable..
Something like the following:
Code:
foreach(DictionaryEntry entry in h1)
{
/*some operation*/
foreach(DictionaryEntry entry1 in h2)
{
/*processing*/
}
}
But it results in an unexpected exception..
How can I do it??
-
January 15th, 2012, 11:25 AM
#2
Re: How to access a hashtable inside another hashtable?
Is there any other way to access the contents of the hashtable without using foreach loop??
-
January 16th, 2012, 11:37 AM
#3
Re: How to access a hashtable inside another hashtable?
The code you've shown doesn't give us enough detail to work with. Also, you didn't mention the error you are getting.
Please give us a more complete code snippet and also specify what exception you are getting.
-
January 16th, 2012, 02:34 PM
#4
Re: How to access a hashtable inside another hashtable?
Well where does h2 come from? If you have a nested dictionary and you want to iterate over the nested one it should be:
Code:
// I have to guess as to what your key is, so I chose int and A,B
var nestedDict = new Dictionary<int, Dictionary<A,B>>();
// populate dictionary
foreach(var dict in nestedDict.Values)
{
// 'dict' is a Dictionary<A,B>
}
If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.
Yes; I have a blog too - http://the-angry-gorilla.com/
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|