Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / February 2007

Tip: Looking for answers? Try searching our database.

Hashtable MultiMap

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aryan - 01 Feb 2007 16:43 GMT
Hi,

I hope someone can help me with the following prob..

I need to implement a hashtable (or a dictionary) whose KEYs are
strings and VLAUEs are
again hashtables.
ie key - is a string and value -is another hashtable .
I want to implement it in C# .net  but dont know the proper syntax to
start with. Is it possible with C# 2.0 generics?

Please help.

Thanks & regards ,

aryan.
Michael Nemtsev - 01 Feb 2007 19:27 GMT
Hello Aryan,

What's wrong with custom collection?!
Start from there http://www.ondotnet.com/pub/a/dotnet/2003/09/02/ilist.html
or see Power Collection for .NET http://www.wintellect.com/PowerCollections.aspx

A> hope someone can help me with the following prob..
A> I need to implement a hashtable (or a dictionary) whose KEYs are
A> strings and VLAUEs are
A> again hashtables.
A> ie key - is a string and value -is another hashtable .
A> I want to implement it in C# .net but dont know the proper syntax to
A> start with. Is it possible with C# 2.0 generics?
A> Please help.
A> Thanks & regards ,
A> aryan.
---
WBR,  Michael  Nemtsev [C# MVP]    blog: http://spaces.live.com/laflour
team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Brian Gideon - 01 Feb 2007 19:56 GMT
> Hi,
>
[quoted text clipped - 12 lines]
>
> aryan.

Aryan,

What about Dictionary<string, Dictionary<TKey, TValue>> where TKey and
TValue are types you choose for the stored Dictionary.

Brian
Robson Siqueira - 01 Feb 2007 22:05 GMT
I would go Dictionary, rather than Hashtable only. You could use only
hashtable for that, since the hashtable stores any type of object as value.
But with Dictionary, you stop that boxing/unboxing thing.

Signature

Regards,
Robson Siqueira
Enterprise Architect

> Hi,
>
[quoted text clipped - 12 lines]
>
> aryan.
aryan - 03 Feb 2007 09:55 GMT
Thanks ebery one for your help .... i have tried it...

n here it goes....

//********************
namespace DictionaryDemo
{
   public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();
       }

       private void button1_Click(object sender, EventArgs e)
       {
           Dictionary<string, Dictionary<string, string>> dict =
               new Dictionary<string, Dictionary<string, string>>();

           dict.Add("Key", new Dictionary<string, string>());
           dict["BaseKey"].Add("SubKey", "Value");

           foreach (KeyValuePair<string, Dictionary<string, string>>
entry in dict)
           {
               listBox1.Items.Add(entry.Key);
               foreach (KeyValuePair<string, string> subEntry in
dict[entry.Key])
               {
                   listBox2.Items.Add(subEntry.Key);
                   foreach (string str in dict[entry.Key].Values)
                   {
                       listBox2.Items.Add(str);
                   }
               }
           }

       }
   }
}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.