Solved

Generic Dictionary Linking?

Posted on 2009-05-15
5
317 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now