Solved

Generic Dictionary Linking?

Posted on 2009-05-15
5
320 Views
Last Modified: 2012-05-07
I need a generic Dictionary like this: Dictionary<int, string, string, string>.

Q. Is there a way to link/gang Dictionary's together to build larger ones?

Note: I've already discovered this one, but I'm looking for another alternative. http://www.aronweiler.com/2009/02/multi-key-generic-dictionary-class-for.html
0
Comment
Question by:pointeman
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:ViceroyFizzlebottom
ID: 24397380
I don't know if I'm interpreting your question correctly, but could you simply use a IList<string> lookup? Using the int as a key, you could then have access to the three strings, but you wouldn't be constrained by the content going into the IList.

Dictionary<int, IList<string>>
0
 

Author Comment

by:pointeman
ID: 24398042
Over my head on that one. Do you have a code example?
0
 
LVL 6

Accepted Solution

by:
ViceroyFizzlebottom earned 500 total points
ID: 24398139
I don't know what you're trying to store in the Dictionary, but here is kindof an example:


string custName = "Fred";
            string custAddress = "12345 Street 1";
            string custZip = "90210";
            int custId = 1;
 
            IList<string> custData = new List<string>();
            custData.Add(custName);
            custData.Add(custAddress);
            custData.Add(custZip);
 
            //Now we want to store all this information for easy retrieval later
            Dictionary<int, IList<string>> dictionary = new Dictionary<int, IList<string>>();
            dictionary.Add(custId, custData);
 
            // Now to access data for a customer
            if (dictionary.ContainsKey(1))
            {
                IList<string> newCustData = dictionary[1];
                foreach (string item in newCustData)
                {
                    Console.WriteLine(item);
                }
            }

Open in new window

0
 

Author Comment

by:pointeman
ID: 24411791
Great example. I'm working with it as we speak...
0
 

Author Closing Comment

by:pointeman
ID: 31581977
Excellent... Thank You
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question