Solved

Generic Dictionary Linking?

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
need to convert function to c# 5 45
Selenium and Xpath 4 32
Need help with another query 10 39
Trigger C# code inside the SQL Server 6 35
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

733 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