What would be the best C# data structure for using one key, and having two values pulled out?
Essentially I need a Dictionary<string, string, string>. Is there something like this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using .NET 4, you could use
If you’re not, you could create your own
Tupletype which works the same way 🙂Alternatively, if you only need this in one place you could create your own type which encapsulated the two strings neatly using appropriate names. For example:
Then you can use:
which makes it very clear what’s going to be stored.
You could implement equality etc if you wanted to. Personally I would like to see this sort of thing made easier – anonymous types nearly do it, but then you can’t name them…