using System.Collections.Generic;
public static void Main()
var key1 = new List<int> { 1, 3, 5 };
var key2 = new List<int> { 2, 4, 6 };
var key3 = new List<int> { 1, 3, 5 };
var comparer = new IEnumerableComparer<int>();
var dictionary = new Dictionary<List<int>, string>(comparer);
dictionary.Add(key1, "hello");
dictionary.Add(key2, "world");
Console.WriteLine(dictionary[key3]);
public class IEnumerableComparer<T> : IEqualityComparer<IEnumerable<T>>
public bool Equals(IEnumerable<T> x, IEnumerable<T> y)
return Object.ReferenceEquals(x, y) || (x != null && y != null && x.SequenceEqual(y));
public int GetHashCode(IEnumerable<T> obj)
return obj.Where(e => e != null).Select(e => e.GetHashCode()).Aggregate(17, (a, b) => 23 * a + b);