Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Generic Dictionary Linking?

Posted on 2009-05-15
5
Medium Priority
?
325 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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