Solved

Generic Dictionary Linking?

Posted on 2009-05-15
5
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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