How to get a IDictionnay form a IList
Share
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.
You can use Linq to easily get a Dictionary from a List by using the ToDictionary extension method and supplying an expression to get the key – e.g.
Alternatively, as Jon pointed out, if you need to use a different value for the Dictionary entries, you can also specify a second expression to get the value – as follows: