See below; I expect the problem is that you are passing a *different*
list that has the same data. By default, the lists are compared for
object (reference) equality. It is possible to override this behavior by
performing a custom comparison (so that two lists with the same contents
are treated as equal). Let me know if you need this.
Marc
class Program
{
static void Main()
{
Dictionary<List<string>, List<string>> lookup = new
Dictionary<List<string>, List<string>>();
lookup.Add(Wrap("a", "b"), Wrap("c", "d", "e"));
lookup.Add(Wrap("f"), Wrap("g", "h"));
List<string> firstKey = null;
foreach (KeyValuePair<List<string>, List<string>> pair in lookup)
{
if (firstKey == null) firstKey = pair.Key;
Write(pair.Key, "Key");
Write(pair.Value, "Value");
}
if (lookup.ContainsKey(firstKey))
{
List<string> value = lookup[firstKey];
Write(value, "Value By Key");
}
}
static void Write<T>(List<T> list, string caption)
{
Console.WriteLine(caption);
foreach (T t in list)
{
Console.WriteLine("\t{0}", t);
}
}
static List<T> Wrap<T>(params T[] args)
{
return new List<T>(args);
}
}