[Solved] Dictionary one key many values in code c#


Make a dictionary with List<string> as value, and then just add values :

foreach(var d in c)
{
  if (!dict.ContainsKey(d.Key))
    dict.Add(d.Key, new List<string>());
  dict[d.Key].Add(d.Value);
}

and later you can get comma delimited string from list with string.Join

string commaDelimitedList = string.Join(",", valueList.ToArray());

solved Dictionary one key many values in code c#