This may seem an odd thing to want to do but ignoring that, is there a nice concise way of converting a
Dictionary<string, string> where each Key Value Pair in the Dictionary is just each string in the List. i.e.
List = string1, string2, string3 Dictionary = string1/string1, string2/string2, string3/string3
I have done plenty of searching and there are literally dozens of examples on Stackoverflow alone of doing it in the opposite direction but not this way round.
The reason for doing this is I have two third part components and changing them is out of my hands. One returns a list of email addresses as a
List<string> and the other send emails where the To parameter is a
Dictionary<string, string>. The key of the dictionary is the email address and the value is their real name. However, I don't know the real name but it still works if you set the real name to the email address as well. Therefore why I want to convert a List to a
Dictionary<string, string>. There are plenty of ways of doing this. A
foreach loop on the list which adds a kvp to a dictionary. But I like terse code and wondered if there was a single line solution.