0

Can i replace the following with a tuple and a list. Will there be any dip in performance or what is the best alternative.

1. Dictionary<string, Dictionary<string, User>>

Can I change this to the following

2. Dictionary<string, Tuple<string, Address>> userdata

Kindly suggest. Note: There seems to be no way to group tuples, so i think that 2 may be better be replaced by 1.

1
  • Of course you can group tuples if they are in a List - use LINQ. Commented Jul 11, 2011 at 8:26

1 Answer 1

2

Tuple will hold exactly one pair of values. Dictionary will hold an arbitraty number of such pairs. So of course 1 and 2 are not equivalent - one holds a collection of collections of pairs, another just a collection of pairs.

slugster is correct: you can group a list of tuples using linq GroupBy method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.