fork(1) download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var sourceDictionary=new Dictionary<string, List<string>>();
  10. sourceDictionary.Add("A", new List<string>() { "A", "A", "B"});
  11. sourceDictionary.Add("B", new List<string>() { "C", "D", "D" });
  12.  
  13. var distinctDict = sourceDictionary.ToDictionary(kv => kv.Key, kv => kv.Value.Distinct());
  14. foreach(var kv in distinctDict)
  15. Console.WriteLine("Key:{0} Values:{1}", kv.Key, string.Join(",", kv.Value.ToArray()));
  16. }
  17. }
Success #stdin #stdout 0.04s 34048KB
stdin
Standard input is empty
stdout
Key:A Values:A,B
Key:B Values:C,D